Adds initial state generation

This commit is contained in:
Nemo 2018-01-28 05:52:14 +05:30
parent b787919aa6
commit 7dfcc5282f
1 changed files with 12 additions and 7 deletions

View File

@ -7,12 +7,9 @@ import random
# First let us create all the cards in the game
state = game.State.new_message()
# Initialize the cardlist
state.init('cardlist', 36)
# 0-8 indexes as per state.capnp
# TODO: Read the strings out of the state definition
houses = ["empty", "varys", "tully", "tyrell", "baratheon", "targaryen", "lannister", "greyjoy", "stark"]
cards = []
for x in xrange(1, 9):
@ -23,10 +20,18 @@ for x in xrange(1, 9):
pass
random.shuffle(cards)
# print(cards)
cardlist = state.init('cardlist', 36)
for index, card in enumerate(cards):
location = game.Location.new_message()
location.board.x = index/6
location.board.x = index / 6
location.board.x = index % 6
cards[index].location = location
card.location = location
cardlist[index] = card
# print(state)
# Now we have an initial state of the game, write it down
f = open('state.bin', 'w+b')
state.write(f)