check if it works
This commit is contained in:
parent
e8fb679f5e
commit
ba3758e93f
2 changed files with 20 additions and 3 deletions
|
@ -11,7 +11,7 @@ from state import Table, Hand
|
|||
from metro_holografix.cardtypes import *
|
||||
import state
|
||||
|
||||
logging.basicConfig(level=logging.INFO, filename='game.log', filemode='w', format='%(levelname)s - %(message)s')
|
||||
logging.basicConfig(level=logging.INFO, filename='game.log', filemode='a', format='%(levelname)s - %(message)s')
|
||||
logging.info("START")
|
||||
|
||||
action = ''
|
||||
|
@ -190,7 +190,7 @@ def spawn_and_wait(tstr, difficulty):
|
|||
os.close(w)
|
||||
p = os.waitpid(pid, os.WNOHANG)
|
||||
while p == (0, 0):
|
||||
# animate(10)
|
||||
animate(10)
|
||||
p = os.waitpid(pid, os.WNOHANG)
|
||||
r = os.fdopen(r)
|
||||
output = r.read()
|
||||
|
@ -234,6 +234,7 @@ def main(difficulty):
|
|||
global exit, action
|
||||
|
||||
game = state.State(["bot1", ID])
|
||||
# game = state.State([ID, "bot1"])
|
||||
|
||||
game.next_turn()
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@ import json
|
|||
from copy import deepcopy as copy
|
||||
from functools import cmp_to_key
|
||||
|
||||
from time import sleep
|
||||
|
||||
from IPython import embed as fuck
|
||||
|
||||
from metro_holografix.cardtypes import *
|
||||
|
@ -17,9 +19,23 @@ class Table(Tavolo):
|
|||
def flatten(self):
|
||||
return [c for tc in self.cards for c in tc.cards]
|
||||
|
||||
def split_repr(self, ocards):
|
||||
l = len(ocards)
|
||||
if l == 13:
|
||||
return ocards
|
||||
else:
|
||||
i = l-1
|
||||
while ocards[i].value-1 == ocards[i-1].value:
|
||||
i -= 1
|
||||
return ocards[i:] + ocards[:i]
|
||||
|
||||
def widget_repr(self):
|
||||
for ts in self.cards:
|
||||
ocards = list(sorted(ts.cards, key=lambda c: c.value))
|
||||
|
||||
if ts.tipo == 'Scala' and ocards[-1].value == 13 and ocards[0].value == 1:
|
||||
ocards = self.split_repr(ocards)
|
||||
|
||||
yi = [sym.big['hat']]
|
||||
seed = ocards[0][0].lower()
|
||||
yi.append(sym.big[seed])
|
||||
|
@ -65,7 +81,7 @@ def make_deck():
|
|||
yield Card(seed, i)
|
||||
odeck = [m for seed in ['Pikes', 'Hearts', 'Clovers', 'Tiles'] for m in make_set(seed)] * 2
|
||||
shuffle(odeck)
|
||||
assert len(odeck) == 104
|
||||
assert len(odeck) == 104
|
||||
return odeck
|
||||
|
||||
class WrongMoveException(Exception):
|
||||
|
|
Loading…
Reference in a new issue