Erste Funktionalitäten, Docstrings auf Sphinx-Format geändert

Zur Änderung der Docstrings pyment eingesetzt.
z.B.
```
pyment -w Field.py
```
master
Martin Putzlocher 2022-04-19 09:49:45 +02:00
parent 6ae7a34f1a
commit 55d804f3bc
9 changed files with 197 additions and 102 deletions

View File

@ -1,58 +1,72 @@
from House import *
from Field import *
import House
import Field
class Board(object):
"""
:version:
:author:
""":version: 0.1
:author: Martin Putzlocher
"""
""" ATTRIBUTES
dict_all_fields (private)
list_all_fields (private)
"""
def get_house_by_color(self, color = "black"):
"""
def __init__(self, colors:list, number_of_players=4):
self.colors = colors
self.num_players = number_of_players
self._list_all_fields = list()
self.init_board()
def get_house_by_color(self, color = "black"):
"""Returns list of house fields of one color
:param string: color :
:param color: (Default value = "black")
:returns: House :
@param string color :
@return House :
@author
"""
pass
def init_board(self):
"""
"""Initialize Board
:returns: author
@return :
@author
"""
pass
for n in range(self.num_players):
for i in range(10):
f = Field.Field(self, i, self.colors[n], house=False)
self._list_all_fields.append(f)
IDlist = [f.get_id() for f in self._list_all_fields]
print(IDlist)
def get_next_standard_field(self, current_field):
"""
@param Field current_field :
@return Field :
:param Field: current_field :
:param current_field:
:returns: Field :
@author
"""
pass
def get_next_field_by_color(self, current_field, color = "black"):
"""
@param Field current_field : Current field
@param string color : Color of the stone requesting his next field.
@return Field :
:param Field: current_field : Current field
:param string: color : Color of the stone requesting his next field.
:param current_field:
:param color: (Default value = "black")
:returns: Field :
@author
"""
pass
curr_id = current_field.get_id()

View File

@ -1,10 +1,12 @@
from Board import *
import Board
class Field():
""" Class of single field on game board
:version: 0.1
:author: Martin Putzlocher
class Field(object):
"""
:version:
:author:
"""
""" ATTRIBUTES
@ -19,16 +21,47 @@ class Field(object):
"""
def get_next_field(self, color_of_stone = "black"):
def __init__(self, board:Board.Board=None, number:int=0, color:str="black", house:bool=False):
if board is None:
raise Exception("No Board Exception")
self.board = board
self._n = number
self._c = color
self._h = house
self._id = ""
self.set_id(color, number, house)
def get_id(self):
""" Get ID of field instance
"""
Give back next field on board, dependent on the color of a stone on the current
return self._id
def set_id(self, color:str, number:int, house:bool):
""" Set ID of field instance
:param color:str:
:param number:int:
:param house:bool:
"""
if house:
assert 0 <= number <= 3
self._id = "H" + color[:3] + str(number)
else:
assert 0 <= number <= 10
self._id = "S" + color[:3] + str(number)
return self._id
def get_next_field(self, color_of_stone = "black"):
"""Give back next field on board, dependent on the color of a stone on the current
field.
@param string color_of_stone :
@return Field :
@author
:param color_of_stone: Default value = "black")
:returns: Field :
@author : Martin Putzlocher
"""
pass
return self.board.get_next_field_by_color(self, color_of_stone)

View File

@ -4,9 +4,10 @@ from GameView import *
class GameController(object):
"""
:version:
""":version:
:author:
"""
""" ATTRIBUTES
@ -19,26 +20,43 @@ class GameController(object):
"""
def add_player(self, name, color):
"""
COLORS=["black", "yellow", "green", "red", "blue", "purple"]
def __init__(self, number_of_players:int=4):
self.list_of_players = list()
for i in range(number_of_players):
self.add_player("Player " + str(i), GameController.COLORS[i])
self.board = Board(GameController.COLORS, number_of_players)
self.game_view = GameView()
def add_player(self, name, color):
"""Add a player to the game
:param name: Name of the player
:param color: Color of the player
:returns: Player : p
@param string name :
@param string color :
@return Player :
@author
"""
pass
p = Player(name, color)
self.list_of_players.append(p)
return p
def remove_player(self, color):
""" Remove player from game
:param color: Color of the player to be removed
:returns: True
"""
@param string color :
@return :
@author
"""
pass
found = False
for p in self.list_of_players:
if p.color == color:
self.list_of_players.remove(p)
found = True
print("Player with color {} removed".format(color))
else:
pass # still not found
if found == False:
print("No player with color {} available for extractin.".format(color))
return True

View File

@ -1,26 +1,27 @@
class GameView(object):
"""
:version:
""":version:
:author:
"""
def display_board(self):
"""
@return :
@author
:returns: author
"""
pass
def update_board(self):
"""
@return :
@author
:returns: author
"""
pass

View File

@ -1,9 +1,11 @@
from Field import *
class House():
""":version: 0.1
:author: Martin Putzlocher
class House(object):
"""
:version:
:author:
"""
""" ATTRIBUTES
@ -14,5 +16,20 @@ class House(object):
"""
def __init__(self, board:Board=None, color:str="black"):
self.board = board
self.color = color
self._list_of_housefields = list()
if board is None:
pass
else:
self.init_house()
def set_board(self, board:Board=None):
self.board = board
return True
def init_house(self):
for i in range(4):
f = Field(board=self.board)

View File

@ -1,9 +1,8 @@
from GameController import *
from House import *
class Player(object):
"""
class Player():
""" Player
:version:
:author:
"""
@ -20,39 +19,45 @@ class Player(object):
"""
def __init__(self, name:str="Nobody", color:str="black"):
self.name = name
self.color = color
self.house = House()
self.set_of_stones = list()
def take_turn(self):
"""
@return :
@author
:returns: author
"""
pass
def throw_dice(self):
"""
@return :
@author
:returns: author
"""
pass
def choose_stone(self):
"""
@return :
@author
:returns: author
"""
pass
def move_stone(self):
"""
@return :
@author
:returns: author
"""
pass

View File

@ -2,9 +2,10 @@ from Field import *
class Position(object):
"""
:version:
""":version:
:author:
"""
""" ATTRIBUTES
@ -21,20 +22,20 @@ class Position(object):
def init_pos(self):
"""
@return :
@author
:returns: author
"""
pass
def change_pos(self, num):
"""
@param int num :
@return :
@author
:param int: num :
:param num:
:returns: author
"""
pass

View File

@ -3,9 +3,10 @@ from Player import *
class Stone(object):
"""
:version:
""":version:
:author:
"""
""" ATTRIBUTES
@ -18,20 +19,20 @@ class Stone(object):
def back_to_start(self):
"""
@return :
@author
:returns: author
"""
pass
def set_position(self, position):
"""
@param Position position :
@return :
@author
:param Position: position :
:param position:
:returns: author
"""
pass

5
maedn/maedn.py Normal file
View File

@ -0,0 +1,5 @@
from GameController import *
g = GameController()
print("Game ends here.")