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 *
|
from metro_holografix.cardtypes import *
|
||||||
import state
|
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")
|
logging.info("START")
|
||||||
|
|
||||||
action = ''
|
action = ''
|
||||||
|
@ -190,7 +190,7 @@ def spawn_and_wait(tstr, difficulty):
|
||||||
os.close(w)
|
os.close(w)
|
||||||
p = os.waitpid(pid, os.WNOHANG)
|
p = os.waitpid(pid, os.WNOHANG)
|
||||||
while p == (0, 0):
|
while p == (0, 0):
|
||||||
# animate(10)
|
animate(10)
|
||||||
p = os.waitpid(pid, os.WNOHANG)
|
p = os.waitpid(pid, os.WNOHANG)
|
||||||
r = os.fdopen(r)
|
r = os.fdopen(r)
|
||||||
output = r.read()
|
output = r.read()
|
||||||
|
@ -234,6 +234,7 @@ def main(difficulty):
|
||||||
global exit, action
|
global exit, action
|
||||||
|
|
||||||
game = state.State(["bot1", ID])
|
game = state.State(["bot1", ID])
|
||||||
|
# game = state.State([ID, "bot1"])
|
||||||
|
|
||||||
game.next_turn()
|
game.next_turn()
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,8 @@ import json
|
||||||
from copy import deepcopy as copy
|
from copy import deepcopy as copy
|
||||||
from functools import cmp_to_key
|
from functools import cmp_to_key
|
||||||
|
|
||||||
|
from time import sleep
|
||||||
|
|
||||||
from IPython import embed as fuck
|
from IPython import embed as fuck
|
||||||
|
|
||||||
from metro_holografix.cardtypes import *
|
from metro_holografix.cardtypes import *
|
||||||
|
@ -17,9 +19,23 @@ class Table(Tavolo):
|
||||||
def flatten(self):
|
def flatten(self):
|
||||||
return [c for tc in self.cards for c in tc.cards]
|
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):
|
def widget_repr(self):
|
||||||
for ts in self.cards:
|
for ts in self.cards:
|
||||||
ocards = list(sorted(ts.cards, key=lambda c: c.value))
|
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']]
|
yi = [sym.big['hat']]
|
||||||
seed = ocards[0][0].lower()
|
seed = ocards[0][0].lower()
|
||||||
yi.append(sym.big[seed])
|
yi.append(sym.big[seed])
|
||||||
|
|
Loading…
Reference in a new issue