Adds a init script
This commit is contained in:
parent
2174f64160
commit
b787919aa6
|
@ -7,3 +7,5 @@ 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
|
||||||
|
|
|
@ -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
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue