Adds a init script

This commit is contained in:
Nemo 2018-01-28 05:42:39 +05:30
parent 2174f64160
commit b787919aa6
3 changed files with 45 additions and 10 deletions

View File

@ -7,3 +7,5 @@ end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.py]
indent_size = 4

32
gothok/init Executable file
View File

@ -0,0 +1,32 @@
#!/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()
# Initialize the cardlist
state.init('cardlist', 36)
# 0-8 indexes as per state.capnp
houses = ["empty", "varys", "tully", "tyrell", "baratheon", "targaryen", "lannister", "greyjoy", "stark"]
cards = []
for x in xrange(1, 9):
for y in xrange(0, x):
card = game.Card.new_message()
card.house = houses[x]
cards.append(card)
pass
random.shuffle(cards)
# print(cards)
for index, card in enumerate(cards):
location = game.Location.new_message()
location.board.x = index/6
location.board.x = index % 6
cards[index].location = location

View File

@ -1,14 +1,15 @@
@0xdcf6fa9421875ce0;
enum House {
stark @7;
greyjoy @6;
lannister @5;
targaryen @4;
baratheon @3;
tyrell @2;
tully @1;
varys @0;
stark @8;
greyjoy @7;
lannister @6;
targaryen @5;
baratheon @4;
tyrell @3;
tully @2;
varys @1;
empty @0;
}
struct Location {
@ -26,7 +27,7 @@ struct Location {
}
struct Card {
house @0 :House;
house @0 :House = empty;
location @1 :Location;
}