Browse Source

Adds a init script

master
Nemo 3 years ago
parent
commit
b787919aa6
  1. 4
      .editorconfig
  2. 32
      gothok/init
  3. 19
      gothok/state.capnp

4
.editorconfig

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

32
gothok/init

@ -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

19
gothok/state.capnp

@ -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;
}

Loading…
Cancel
Save