37 lines
903 B
Python
Executable File
37 lines
903 B
Python
Executable File
#!/usr/bin/env python
|
|
|
|
import capnp
|
|
import state_capnp as game
|
|
import random
|
|
|
|
# First let us create all the cards in the game
|
|
state = game.State.new_message()
|
|
|
|
# 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 range(1, 9):
|
|
for y in range(0, x):
|
|
card = game.Card.new_message()
|
|
card.house = houses[x]
|
|
cards.append(card)
|
|
pass
|
|
|
|
random.shuffle(cards)
|
|
|
|
cardlist = state.init('cardlist', 36)
|
|
|
|
for index, card in enumerate(cards):
|
|
location = game.Location.new_message()
|
|
location.board.x = index / 6
|
|
location.board.y = index % 6
|
|
card.location = location
|
|
cardlist[index] = card
|
|
|
|
# Now we have an initial state of the game, write it down
|
|
f = open('state.bin', 'w+b')
|
|
state.write_packed(f)
|
|
f.close()
|