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

@ -6,4 +6,6 @@ indent_size = 2
end_of_line = lf end_of_line = lf
charset = utf-8 charset = utf-8
trim_trailing_whitespace = true trim_trailing_whitespace = true
insert_final_newline = 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; @0xdcf6fa9421875ce0;
enum House { enum House {
stark @7; stark @8;
greyjoy @6; greyjoy @7;
lannister @5; lannister @6;
targaryen @4; targaryen @5;
baratheon @3; baratheon @4;
tyrell @2; tyrell @3;
tully @1; tully @2;
varys @0; varys @1;
empty @0;
} }
struct Location { struct Location {
@ -26,7 +27,7 @@ struct Location {
} }
struct Card { struct Card {
house @0 :House; house @0 :House = empty;
location @1 :Location; location @1 :Location;
} }