opale/opale/board.py
Pierre-Olivier Mercier 36318c7d70 Hat the artist! mmmmmm
2020-03-12 20:04:13 +01:00

103 lines
2.6 KiB
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Mar 4 22:23:56 2020
@author: AlexandreMouchel
"""
from opale.carte import *
class Board():
def __init__(self):
self.chasseresse = []
self.dragonCorail = []
self.pearl = []
self.witch = []
self.dragonPetrified = []
self.golem = []
self.guardian = []
self.horser = []
self.city = []
self.underTheBoard = []
self.roundCity = 0
def isFinished(self):
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