Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- START=200
- import random
- class Player:
- def __init__(self,name):
- self.name=name
- self.pos=0
- self.balance=1500
- def move(self,steps):
- self.pos+=steps
- def pay(self,amount):
- self.balance-=amount
- def get(self,amount):
- self.balance+=amount
- def pay_to(self,player, amount):
- self.balance-=amount
- player.get(amount)
- def roll(self):
- a,b = random.randint(1,6), random.randint(1,6)
- return a,b
- @property
- def balance(self):
- return self.balance
- @property
- def pos(self):
- return self.pos
- @property
- def name(self):
- return self.name
- @pos.setter
- def pos(self, where, start):
- if start and self.pos>where:
- self.balance+=START
- self.pos=where
- @name.setter
- def name(self, new):
- self.name=new
- @balance.setter
- def balance(self, new):
- self.balance=new
- class Field:
- pass
- class Go(Field):
- class Board:
- def __init__(self):
- self.fields = {0:Go()}
- from player import player
- from board import board
- class Game:
- def __init__(self, players, board):
- self.players = []
- self.board = board
- for i in range(players):
- name = f"P{i+1}"
- self.players.append(Player(name))
- def start(self):
- for p in self.players:
- p.balance=1500
- for i in range(10):
- for p in players:
- a,b = p.roll()
- p.move(a+b)
- if a==b:
- a,b=p.roll()
- p.move(a+b)
- from game import Game
- b = Board()
- game = Game(4,b)
- gane.start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement