Hat the artist! mmmmmm
This commit is contained in:
parent
da29b8fc1b
commit
36318c7d70
@ -6,8 +6,10 @@ Created on Wed Mar 4 22:23:56 2020
|
|||||||
@author: AlexandreMouchel
|
@author: AlexandreMouchel
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from opale.carte import *
|
||||||
|
|
||||||
class Board():
|
class Board():
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.chasseresse = []
|
self.chasseresse = []
|
||||||
self.dragonCorail = []
|
self.dragonCorail = []
|
||||||
@ -20,7 +22,81 @@ class Board():
|
|||||||
self.city = []
|
self.city = []
|
||||||
self.underTheBoard = []
|
self.underTheBoard = []
|
||||||
self.roundCity = 0
|
self.roundCity = 0
|
||||||
|
|
||||||
def isFinished(self):
|
def isFinished(self):
|
||||||
return self.roundCity >= 3
|
return self.roundCity >= 3
|
||||||
|
|
||||||
|
def play_card(self, *cards):
|
||||||
|
ret = []
|
||||||
|
|
||||||
|
for card in cards:
|
||||||
|
if type(card) == Chasseresse:
|
||||||
|
self.chasseresse.append(card)
|
||||||
|
|
||||||
|
if len(self.chasseresse) >= 3:
|
||||||
|
self.underTheBoard += self.chasseresse
|
||||||
|
self.chasseresse = []
|
||||||
|
|
||||||
|
ret += self.dragonCorail
|
||||||
|
self.dragonCorail = []
|
||||||
|
|
||||||
|
elif type(card) == DragonCorail:
|
||||||
|
self.dragonCorail.append(card)
|
||||||
|
|
||||||
|
ret += self.pearl
|
||||||
|
self.pearl = []
|
||||||
|
|
||||||
|
elif type(card) == Pearl:
|
||||||
|
self.pearl.append(card)
|
||||||
|
|
||||||
|
elif type(card) == Witch:
|
||||||
|
self.witch.append(card)
|
||||||
|
|
||||||
|
ret += self.pearl
|
||||||
|
self.pearl = []
|
||||||
|
|
||||||
|
ret += self.dragonPetrified
|
||||||
|
self.dragonPetrified = []
|
||||||
|
|
||||||
|
elif type(card) == DragonPetrified:
|
||||||
|
self.dragonPetrified.append(card)
|
||||||
|
|
||||||
|
elif type(card) == Golem:
|
||||||
|
self.golem.append(card)
|
||||||
|
|
||||||
|
ret += self.witch
|
||||||
|
self.witch = []
|
||||||
|
|
||||||
|
elif type(card) == Guardian:
|
||||||
|
self.guardian.append(card)
|
||||||
|
|
||||||
|
if len(self.guardian) >= 4:
|
||||||
|
ret += self.guardian
|
||||||
|
self.guardian = []
|
||||||
|
|
||||||
|
elif type(card) == Horser:
|
||||||
|
self.horser.append(card)
|
||||||
|
|
||||||
|
if len(self.horser) >= 2:
|
||||||
|
ret += self.witch
|
||||||
|
ret += self.golem
|
||||||
|
self.witch = []
|
||||||
|
self.golem = []
|
||||||
|
|
||||||
|
self.underTheBoard += self.horser
|
||||||
|
self.horser = []
|
||||||
|
|
||||||
|
elif type(card) == City:
|
||||||
|
self.city.append(card)
|
||||||
|
|
||||||
|
if len(self.city) >= 3:
|
||||||
|
self.roundCity += 1
|
||||||
|
self.city = []
|
||||||
|
|
||||||
|
ret += self.underTheBoard
|
||||||
|
self.underTheBoard = []
|
||||||
|
|
||||||
|
else:
|
||||||
|
raise Exception("Unknown card type " + type(card).__name__)
|
||||||
|
|
||||||
|
return ret
|
||||||
|
@ -6,10 +6,30 @@ Created on Wed Mar 4 22:20:15 2020
|
|||||||
@author: AlexandreMouchel
|
@author: AlexandreMouchel
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from board import Board
|
||||||
|
from player import Player
|
||||||
|
|
||||||
class Game():
|
class Game():
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.board = Board()
|
self.board = Board()
|
||||||
self.player1 = Player()
|
self.player1 = Player()
|
||||||
self.player2 = Player()
|
self.player2 = Player()
|
||||||
self.round = 0
|
self.round = 0
|
||||||
|
|
||||||
|
from carte import *
|
||||||
|
|
||||||
|
c1 = Pearl(2)
|
||||||
|
c2 = Pearl(1)
|
||||||
|
|
||||||
|
game = Game()
|
||||||
|
print(game.board.play_card(c1, c2))
|
||||||
|
|
||||||
|
c3 = DragonCorail(2)
|
||||||
|
print(game.board.play_card(c3))
|
||||||
|
|
||||||
|
c4 = City()
|
||||||
|
print(game.board.play_card(c4, c4, c4))
|
||||||
|
print(game.board.play_card(c4, c4, c4))
|
||||||
|
print(game.board.play_card(c4, c4, c4))
|
||||||
|
print(game.board.isFinished())
|
||||||
|
@ -11,12 +11,13 @@ from carte import *
|
|||||||
|
|
||||||
|
|
||||||
class Player():
|
class Player():
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.pioche = []
|
self.pioche = []
|
||||||
self.défausse = []
|
self.défausse = []
|
||||||
self.main = []
|
self.main = []
|
||||||
self.dragonPetrified = False
|
self.dragonPetrified = False
|
||||||
|
|
||||||
# we are creating the deck
|
# we are creating the deck
|
||||||
self.pioche += [City() for i in range(6)]
|
self.pioche += [City() for i in range(6)]
|
||||||
self.pioche += [Chasseresse(1 if i % 3 else 2) for i in range(6)]
|
self.pioche += [Chasseresse(1 if i % 3 else 2) for i in range(6)]
|
||||||
@ -30,18 +31,26 @@ class Player():
|
|||||||
self.pioche += [Guardian(2) for i in range(3)]
|
self.pioche += [Guardian(2) for i in range(3)]
|
||||||
self.pioche += [Guardian(3) for i in range(1)]
|
self.pioche += [Guardian(3) for i in range(1)]
|
||||||
random.shuffle(self.pioche)
|
random.shuffle(self.pioche)
|
||||||
|
|
||||||
def pick(self):
|
def pick(self):
|
||||||
for i in range((6 if self.dragonPetrified else 5) - len(self.main)):
|
for i in range((6 if self.dragonPetrified else 5) - len(self.main)):
|
||||||
self.main.append(self.pioche.pop())
|
self.main.append(self.pioche.pop())
|
||||||
|
|
||||||
|
def lose_dragon(self):
|
||||||
|
self.dragonPetrified = False
|
||||||
|
|
||||||
nde = Player()
|
random.shuffle(self.main)
|
||||||
print(len(nde.pioche))
|
for i in range(len(self.main)):
|
||||||
nde.pick()
|
self.pioche.append(self.main.pop())
|
||||||
nde.dragonPetrified = True
|
|
||||||
nde.pick()
|
|
||||||
print(len(nde.pioche))
|
|
||||||
print(nde.main)
|
|
||||||
|
|
||||||
|
self.pick()
|
||||||
|
|
||||||
|
def take_dragon(self):
|
||||||
|
self.dragonPetrified = True
|
||||||
|
|
||||||
|
def push_défausse(self, *cards):
|
||||||
|
self.défausse += cards
|
||||||
|
|
||||||
|
def play_card(self, *cards):
|
||||||
|
for card in cards:
|
||||||
|
self.main.remove(card)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user