make planetwars great again
This commit is contained in:
parent
9b2faccfd2
commit
c846031aa3
5 changed files with 177 additions and 88 deletions
|
@ -14,3 +14,6 @@ futures = "0.1.28"
|
|||
serde = "1.0.100"
|
||||
serde_derive = "1.0.100"
|
||||
serde_json = "1.0"
|
||||
tracing = "0.1.9"
|
||||
tracing-futures = "0.1.0"
|
||||
tracing-subscriber = "0.1.5"
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
{"planets":[{"ship_count":7,"x":-6.0,"y":0.0,"owner":1,"name":"protos"},{"ship_count":6,"x":-3.0,"y":5.0,"owner":null,"name":"duteros"},{"ship_count":6,"x":3.0,"y":5.0,"owner":null,"name":"tritos"},{"ship_count":7,"x":6.0,"y":0.0,"owner":2,"name":"tetartos"},{"ship_count":6,"x":3.0,"y":-5.0,"owner":null,"name":"pemptos"},{"ship_count":6,"x":-3.0,"y":-5.0,"owner":null,"name":"extos"}],"expeditions":[]}
|
||||
{"planets":[{"ship_count":2,"x":-6.0,"y":0.0,"owner":1,"name":"protos"},{"ship_count":6,"x":-3.0,"y":5.0,"owner":null,"name":"duteros"},{"ship_count":6,"x":3.0,"y":5.0,"owner":null,"name":"tritos"},{"ship_count":2,"x":6.0,"y":0.0,"owner":2,"name":"tetartos"},{"ship_count":6,"x":3.0,"y":-5.0,"owner":null,"name":"pemptos"},{"ship_count":6,"x":-3.0,"y":-5.0,"owner":null,"name":"extos"}],"expeditions":[{"id":0,"ship_count":6,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":10},{"id":1,"ship_count":6,"origin":"protos","destination":"duteros","owner":1,"turns_remaining":5}]}
|
||||
{"planets":[{"ship_count":2,"x":-6.0,"y":0.0,"owner":1,"name":"protos"},{"ship_count":6,"x":-3.0,"y":5.0,"owner":null,"name":"duteros"},{"ship_count":6,"x":3.0,"y":5.0,"owner":null,"name":"tritos"},{"ship_count":2,"x":6.0,"y":0.0,"owner":2,"name":"tetartos"},{"ship_count":6,"x":3.0,"y":-5.0,"owner":null,"name":"pemptos"},{"ship_count":6,"x":-3.0,"y":-5.0,"owner":null,"name":"extos"}],"expeditions":[{"id":0,"ship_count":6,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":9},{"id":1,"ship_count":6,"origin":"protos","destination":"duteros","owner":1,"turns_remaining":4},{"id":2,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":11},{"id":3,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":11}]}
|
||||
{"planets":[{"ship_count":2,"x":-6.0,"y":0.0,"owner":1,"name":"protos"},{"ship_count":6,"x":-3.0,"y":5.0,"owner":null,"name":"duteros"},{"ship_count":6,"x":3.0,"y":5.0,"owner":null,"name":"tritos"},{"ship_count":2,"x":6.0,"y":0.0,"owner":2,"name":"tetartos"},{"ship_count":6,"x":3.0,"y":-5.0,"owner":null,"name":"pemptos"},{"ship_count":6,"x":-3.0,"y":-5.0,"owner":null,"name":"extos"}],"expeditions":[{"id":0,"ship_count":6,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":8},{"id":1,"ship_count":6,"origin":"protos","destination":"duteros","owner":1,"turns_remaining":3},{"id":2,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":10},{"id":3,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":10},{"id":4,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":11},{"id":5,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":11}]}
|
||||
{"planets":[{"ship_count":2,"x":-6.0,"y":0.0,"owner":1,"name":"protos"},{"ship_count":6,"x":-3.0,"y":5.0,"owner":null,"name":"duteros"},{"ship_count":6,"x":3.0,"y":5.0,"owner":null,"name":"tritos"},{"ship_count":2,"x":6.0,"y":0.0,"owner":2,"name":"tetartos"},{"ship_count":6,"x":3.0,"y":-5.0,"owner":null,"name":"pemptos"},{"ship_count":6,"x":-3.0,"y":-5.0,"owner":null,"name":"extos"}],"expeditions":[{"id":0,"ship_count":6,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":7},{"id":1,"ship_count":6,"origin":"protos","destination":"duteros","owner":1,"turns_remaining":2},{"id":2,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":9},{"id":3,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":9},{"id":4,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":10},{"id":5,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":10},{"id":6,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":11},{"id":7,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":11}]}
|
||||
{"planets":[{"ship_count":2,"x":-6.0,"y":0.0,"owner":1,"name":"protos"},{"ship_count":6,"x":-3.0,"y":5.0,"owner":null,"name":"duteros"},{"ship_count":6,"x":3.0,"y":5.0,"owner":null,"name":"tritos"},{"ship_count":2,"x":6.0,"y":0.0,"owner":2,"name":"tetartos"},{"ship_count":6,"x":3.0,"y":-5.0,"owner":null,"name":"pemptos"},{"ship_count":6,"x":-3.0,"y":-5.0,"owner":null,"name":"extos"}],"expeditions":[{"id":0,"ship_count":6,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":6},{"id":1,"ship_count":6,"origin":"protos","destination":"duteros","owner":1,"turns_remaining":1},{"id":2,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":8},{"id":3,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":8},{"id":4,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":9},{"id":5,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":9},{"id":6,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":10},{"id":7,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":10},{"id":8,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":11},{"id":9,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":11}]}
|
||||
{"planets":[{"ship_count":2,"x":-6.0,"y":0.0,"owner":1,"name":"protos"},{"ship_count":0,"x":-3.0,"y":5.0,"owner":null,"name":"duteros"},{"ship_count":6,"x":3.0,"y":5.0,"owner":null,"name":"tritos"},{"ship_count":2,"x":6.0,"y":0.0,"owner":2,"name":"tetartos"},{"ship_count":6,"x":3.0,"y":-5.0,"owner":null,"name":"pemptos"},{"ship_count":6,"x":-3.0,"y":-5.0,"owner":null,"name":"extos"}],"expeditions":[{"id":0,"ship_count":6,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":5},{"id":11,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":11},{"id":2,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":7},{"id":3,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":7},{"id":4,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":8},{"id":5,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":8},{"id":6,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":9},{"id":7,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":9},{"id":8,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":10},{"id":9,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":10},{"id":10,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":11}]}
|
||||
{"planets":[{"ship_count":2,"x":-6.0,"y":0.0,"owner":1,"name":"protos"},{"ship_count":0,"x":-3.0,"y":5.0,"owner":null,"name":"duteros"},{"ship_count":6,"x":3.0,"y":5.0,"owner":null,"name":"tritos"},{"ship_count":2,"x":6.0,"y":0.0,"owner":2,"name":"tetartos"},{"ship_count":6,"x":3.0,"y":-5.0,"owner":null,"name":"pemptos"},{"ship_count":6,"x":-3.0,"y":-5.0,"owner":null,"name":"extos"}],"expeditions":[{"id":0,"ship_count":6,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":4},{"id":11,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":10},{"id":2,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":6},{"id":3,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":6},{"id":4,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":7},{"id":5,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":7},{"id":6,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":8},{"id":7,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":8},{"id":8,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":9},{"id":9,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":9},{"id":10,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":10},{"id":12,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":10},{"id":13,"ship_count":1,"origin":"protos","destination":"duteros","owner":1,"turns_remaining":5}]}
|
||||
{"planets":[{"ship_count":2,"x":-6.0,"y":0.0,"owner":1,"name":"protos"},{"ship_count":0,"x":-3.0,"y":5.0,"owner":null,"name":"duteros"},{"ship_count":6,"x":3.0,"y":5.0,"owner":null,"name":"tritos"},{"ship_count":2,"x":6.0,"y":0.0,"owner":2,"name":"tetartos"},{"ship_count":6,"x":3.0,"y":-5.0,"owner":null,"name":"pemptos"},{"ship_count":6,"x":-3.0,"y":-5.0,"owner":null,"name":"extos"}],"expeditions":[{"id":0,"ship_count":6,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":3},{"id":11,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":9},{"id":2,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":5},{"id":3,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":5},{"id":4,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":6},{"id":5,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":6},{"id":6,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":7},{"id":7,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":7},{"id":8,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":8},{"id":9,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":8},{"id":10,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":9},{"id":12,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":9},{"id":13,"ship_count":1,"origin":"protos","destination":"duteros","owner":1,"turns_remaining":4},{"id":14,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":10},{"id":15,"ship_count":1,"origin":"protos","destination":"duteros","owner":1,"turns_remaining":5}]}
|
||||
{"planets":[{"ship_count":2,"x":-6.0,"y":0.0,"owner":1,"name":"protos"},{"ship_count":0,"x":-3.0,"y":5.0,"owner":null,"name":"duteros"},{"ship_count":6,"x":3.0,"y":5.0,"owner":null,"name":"tritos"},{"ship_count":2,"x":6.0,"y":0.0,"owner":2,"name":"tetartos"},{"ship_count":6,"x":3.0,"y":-5.0,"owner":null,"name":"pemptos"},{"ship_count":6,"x":-3.0,"y":-5.0,"owner":null,"name":"extos"}],"expeditions":[{"id":0,"ship_count":6,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":2},{"id":11,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":8},{"id":2,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":4},{"id":3,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":4},{"id":4,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":5},{"id":5,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":5},{"id":6,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":6},{"id":7,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":6},{"id":8,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":7},{"id":9,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":7},{"id":10,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":8},{"id":12,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":8},{"id":13,"ship_count":1,"origin":"protos","destination":"duteros","owner":1,"turns_remaining":3},{"id":14,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":9},{"id":15,"ship_count":1,"origin":"protos","destination":"duteros","owner":1,"turns_remaining":4},{"id":16,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":10},{"id":17,"ship_count":1,"origin":"protos","destination":"duteros","owner":1,"turns_remaining":5}]}
|
||||
{"planets":[{"ship_count":2,"x":-6.0,"y":0.0,"owner":1,"name":"protos"},{"ship_count":0,"x":-3.0,"y":5.0,"owner":null,"name":"duteros"},{"ship_count":6,"x":3.0,"y":5.0,"owner":null,"name":"tritos"},{"ship_count":2,"x":6.0,"y":0.0,"owner":2,"name":"tetartos"},{"ship_count":6,"x":3.0,"y":-5.0,"owner":null,"name":"pemptos"},{"ship_count":6,"x":-3.0,"y":-5.0,"owner":null,"name":"extos"}],"expeditions":[{"id":0,"ship_count":6,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":1},{"id":11,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":7},{"id":2,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":3},{"id":3,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":3},{"id":4,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":4},{"id":5,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":4},{"id":6,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":5},{"id":7,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":5},{"id":8,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":6},{"id":9,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":6},{"id":10,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":7},{"id":12,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":7},{"id":13,"ship_count":1,"origin":"protos","destination":"duteros","owner":1,"turns_remaining":2},{"id":14,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":8},{"id":15,"ship_count":1,"origin":"protos","destination":"duteros","owner":1,"turns_remaining":3},{"id":16,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":9},{"id":17,"ship_count":1,"origin":"protos","destination":"duteros","owner":1,"turns_remaining":4},{"id":18,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":10},{"id":19,"ship_count":1,"origin":"protos","destination":"duteros","owner":1,"turns_remaining":5}]}
|
||||
{"planets":[{"ship_count":2,"x":-6.0,"y":0.0,"owner":1,"name":"protos"},{"ship_count":6,"x":-3.0,"y":5.0,"owner":2,"name":"duteros"},{"ship_count":6,"x":3.0,"y":5.0,"owner":null,"name":"tritos"},{"ship_count":2,"x":6.0,"y":0.0,"owner":2,"name":"tetartos"},{"ship_count":6,"x":3.0,"y":-5.0,"owner":null,"name":"pemptos"},{"ship_count":6,"x":-3.0,"y":-5.0,"owner":null,"name":"extos"}],"expeditions":[{"id":21,"ship_count":1,"origin":"protos","destination":"duteros","owner":1,"turns_remaining":5},{"id":11,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":6},{"id":2,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":2},{"id":3,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":2},{"id":4,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":3},{"id":5,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":3},{"id":6,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":4},{"id":7,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":4},{"id":8,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":5},{"id":9,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":5},{"id":10,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":6},{"id":12,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":6},{"id":13,"ship_count":1,"origin":"protos","destination":"duteros","owner":1,"turns_remaining":1},{"id":14,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":7},{"id":15,"ship_count":1,"origin":"protos","destination":"duteros","owner":1,"turns_remaining":2},{"id":16,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":8},{"id":17,"ship_count":1,"origin":"protos","destination":"duteros","owner":1,"turns_remaining":3},{"id":18,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":9},{"id":19,"ship_count":1,"origin":"protos","destination":"duteros","owner":1,"turns_remaining":4},{"id":20,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":10}]}
|
||||
{"planets":[{"ship_count":2,"x":-6.0,"y":0.0,"owner":1,"name":"protos"},{"ship_count":1,"x":-3.0,"y":5.0,"owner":2,"name":"duteros"},{"ship_count":6,"x":3.0,"y":5.0,"owner":null,"name":"tritos"},{"ship_count":3,"x":6.0,"y":0.0,"owner":2,"name":"tetartos"},{"ship_count":6,"x":3.0,"y":-5.0,"owner":null,"name":"pemptos"},{"ship_count":6,"x":-3.0,"y":-5.0,"owner":null,"name":"extos"}],"expeditions":[{"id":21,"ship_count":1,"origin":"protos","destination":"duteros","owner":1,"turns_remaining":4},{"id":11,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":5},{"id":2,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":1},{"id":3,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":1},{"id":4,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":2},{"id":5,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":2},{"id":6,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":3},{"id":7,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":3},{"id":8,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":4},{"id":9,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":4},{"id":10,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":5},{"id":12,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":5},{"id":23,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":11},{"id":14,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":6},{"id":15,"ship_count":1,"origin":"protos","destination":"duteros","owner":1,"turns_remaining":1},{"id":16,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":7},{"id":17,"ship_count":1,"origin":"protos","destination":"duteros","owner":1,"turns_remaining":2},{"id":18,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":8},{"id":19,"ship_count":1,"origin":"protos","destination":"duteros","owner":1,"turns_remaining":3},{"id":20,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":9},{"id":22,"ship_count":5,"origin":"duteros","destination":"protos","owner":2,"turns_remaining":5}]}
|
||||
{"planets":[{"ship_count":1,"x":-6.0,"y":0.0,"owner":1,"name":"protos"},{"ship_count":1,"x":-3.0,"y":5.0,"owner":2,"name":"duteros"},{"ship_count":6,"x":3.0,"y":5.0,"owner":null,"name":"tritos"},{"ship_count":1,"x":6.0,"y":0.0,"owner":2,"name":"tetartos"},{"ship_count":6,"x":3.0,"y":-5.0,"owner":null,"name":"pemptos"},{"ship_count":6,"x":-3.0,"y":-5.0,"owner":null,"name":"extos"}],"expeditions":[{"id":21,"ship_count":1,"origin":"protos","destination":"duteros","owner":1,"turns_remaining":3},{"id":11,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":4},{"id":25,"ship_count":1,"origin":"protos","destination":"duteros","owner":1,"turns_remaining":5},{"id":24,"ship_count":2,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":11},{"id":4,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":1},{"id":5,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":1},{"id":6,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":2},{"id":7,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":2},{"id":8,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":3},{"id":9,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":3},{"id":10,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":4},{"id":12,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":4},{"id":23,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":10},{"id":14,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":5},{"id":22,"ship_count":5,"origin":"duteros","destination":"protos","owner":2,"turns_remaining":4},{"id":16,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":6},{"id":17,"ship_count":1,"origin":"protos","destination":"duteros","owner":1,"turns_remaining":1},{"id":18,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":7},{"id":19,"ship_count":1,"origin":"protos","destination":"duteros","owner":1,"turns_remaining":2},{"id":20,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":8}]}
|
||||
{"planets":[{"ship_count":1,"x":-6.0,"y":0.0,"owner":1,"name":"protos"},{"ship_count":1,"x":-3.0,"y":5.0,"owner":2,"name":"duteros"},{"ship_count":6,"x":3.0,"y":5.0,"owner":null,"name":"tritos"},{"ship_count":1,"x":6.0,"y":0.0,"owner":2,"name":"tetartos"},{"ship_count":6,"x":3.0,"y":-5.0,"owner":null,"name":"pemptos"},{"ship_count":6,"x":-3.0,"y":-5.0,"owner":null,"name":"extos"}],"expeditions":[{"id":21,"ship_count":1,"origin":"protos","destination":"duteros","owner":1,"turns_remaining":2},{"id":11,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":3},{"id":25,"ship_count":1,"origin":"protos","destination":"duteros","owner":1,"turns_remaining":4},{"id":24,"ship_count":2,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":10},{"id":20,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":7},{"id":19,"ship_count":1,"origin":"protos","destination":"duteros","owner":1,"turns_remaining":1},{"id":6,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":1},{"id":7,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":1},{"id":8,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":2},{"id":9,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":2},{"id":10,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":3},{"id":12,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":3},{"id":23,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":9},{"id":14,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":4},{"id":22,"ship_count":5,"origin":"duteros","destination":"protos","owner":2,"turns_remaining":3},{"id":16,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":5},{"id":18,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":6}]}
|
||||
{"planets":[{"ship_count":1,"x":-6.0,"y":0.0,"owner":1,"name":"protos"},{"ship_count":1,"x":-3.0,"y":5.0,"owner":2,"name":"duteros"},{"ship_count":6,"x":3.0,"y":5.0,"owner":null,"name":"tritos"},{"ship_count":1,"x":6.0,"y":0.0,"owner":2,"name":"tetartos"},{"ship_count":6,"x":3.0,"y":-5.0,"owner":null,"name":"pemptos"},{"ship_count":6,"x":-3.0,"y":-5.0,"owner":null,"name":"extos"}],"expeditions":[{"id":21,"ship_count":1,"origin":"protos","destination":"duteros","owner":1,"turns_remaining":1},{"id":11,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":2},{"id":25,"ship_count":1,"origin":"protos","destination":"duteros","owner":1,"turns_remaining":3},{"id":24,"ship_count":2,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":9},{"id":20,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":6},{"id":18,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":5},{"id":16,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":4},{"id":22,"ship_count":5,"origin":"duteros","destination":"protos","owner":2,"turns_remaining":2},{"id":8,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":1},{"id":9,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":1},{"id":10,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":2},{"id":12,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":2},{"id":23,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":8},{"id":14,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":3}]}
|
||||
{"planets":[{"ship_count":1,"x":-6.0,"y":0.0,"owner":1,"name":"protos"},{"ship_count":1,"x":-3.0,"y":5.0,"owner":2,"name":"duteros"},{"ship_count":6,"x":3.0,"y":5.0,"owner":null,"name":"tritos"},{"ship_count":1,"x":6.0,"y":0.0,"owner":2,"name":"tetartos"},{"ship_count":6,"x":3.0,"y":-5.0,"owner":null,"name":"pemptos"},{"ship_count":6,"x":-3.0,"y":-5.0,"owner":null,"name":"extos"}],"expeditions":[{"id":14,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":2},{"id":11,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":1},{"id":25,"ship_count":1,"origin":"protos","destination":"duteros","owner":1,"turns_remaining":2},{"id":24,"ship_count":2,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":8},{"id":20,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":5},{"id":18,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":4},{"id":16,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":3},{"id":22,"ship_count":5,"origin":"duteros","destination":"protos","owner":2,"turns_remaining":1},{"id":23,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":7},{"id":12,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":1},{"id":10,"ship_count":1,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":1}]}
|
||||
{"planets":[{"ship_count":4,"x":-6.0,"y":0.0,"owner":2,"name":"protos"},{"ship_count":3,"x":-3.0,"y":5.0,"owner":2,"name":"duteros"},{"ship_count":6,"x":3.0,"y":5.0,"owner":null,"name":"tritos"},{"ship_count":1,"x":6.0,"y":0.0,"owner":2,"name":"tetartos"},{"ship_count":6,"x":3.0,"y":-5.0,"owner":null,"name":"pemptos"},{"ship_count":6,"x":-3.0,"y":-5.0,"owner":null,"name":"extos"}],"expeditions":[{"id":14,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":1},{"id":23,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":6},{"id":25,"ship_count":1,"origin":"protos","destination":"duteros","owner":1,"turns_remaining":1},{"id":24,"ship_count":2,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":7},{"id":20,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":4},{"id":18,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":3},{"id":16,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":2}]}
|
||||
{"planets":[{"ship_count":2,"x":-6.0,"y":0.0,"owner":2,"name":"protos"},{"ship_count":4,"x":-3.0,"y":5.0,"owner":2,"name":"duteros"},{"ship_count":6,"x":3.0,"y":5.0,"owner":null,"name":"tritos"},{"ship_count":2,"x":6.0,"y":0.0,"owner":2,"name":"tetartos"},{"ship_count":6,"x":3.0,"y":-5.0,"owner":null,"name":"pemptos"},{"ship_count":6,"x":-3.0,"y":-5.0,"owner":null,"name":"extos"}],"expeditions":[{"id":26,"ship_count":3,"origin":"protos","destination":"tritos","owner":2,"turns_remaining":10},{"id":23,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":5},{"id":16,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":1},{"id":24,"ship_count":2,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":6},{"id":20,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":3},{"id":18,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":2}]}
|
||||
{"planets":[{"ship_count":3,"x":-6.0,"y":0.0,"owner":2,"name":"protos"},{"ship_count":3,"x":-3.0,"y":5.0,"owner":2,"name":"duteros"},{"ship_count":6,"x":3.0,"y":5.0,"owner":null,"name":"tritos"},{"ship_count":3,"x":6.0,"y":0.0,"owner":2,"name":"tetartos"},{"ship_count":6,"x":3.0,"y":-5.0,"owner":null,"name":"pemptos"},{"ship_count":6,"x":-3.0,"y":-5.0,"owner":null,"name":"extos"}],"expeditions":[{"id":26,"ship_count":3,"origin":"protos","destination":"tritos","owner":2,"turns_remaining":9},{"id":23,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":4},{"id":27,"ship_count":3,"origin":"duteros","destination":"tritos","owner":2,"turns_remaining":5},{"id":24,"ship_count":2,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":5},{"id":20,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":2},{"id":18,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":1}]}
|
||||
{"planets":[{"ship_count":2,"x":-6.0,"y":0.0,"owner":2,"name":"protos"},{"ship_count":5,"x":-3.0,"y":5.0,"owner":2,"name":"duteros"},{"ship_count":6,"x":3.0,"y":5.0,"owner":null,"name":"tritos"},{"ship_count":4,"x":6.0,"y":0.0,"owner":2,"name":"tetartos"},{"ship_count":6,"x":3.0,"y":-5.0,"owner":null,"name":"pemptos"},{"ship_count":6,"x":-3.0,"y":-5.0,"owner":null,"name":"extos"}],"expeditions":[{"id":26,"ship_count":3,"origin":"protos","destination":"tritos","owner":2,"turns_remaining":8},{"id":23,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":3},{"id":27,"ship_count":3,"origin":"duteros","destination":"tritos","owner":2,"turns_remaining":4},{"id":24,"ship_count":2,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":4},{"id":20,"ship_count":1,"origin":"tetartos","destination":"duteros","owner":2,"turns_remaining":1},{"id":28,"ship_count":2,"origin":"protos","destination":"tritos","owner":2,"turns_remaining":10}]}
|
||||
{"planets":[{"ship_count":3,"x":-6.0,"y":0.0,"owner":2,"name":"protos"},{"ship_count":3,"x":-3.0,"y":5.0,"owner":2,"name":"duteros"},{"ship_count":6,"x":3.0,"y":5.0,"owner":null,"name":"tritos"},{"ship_count":5,"x":6.0,"y":0.0,"owner":2,"name":"tetartos"},{"ship_count":6,"x":3.0,"y":-5.0,"owner":null,"name":"pemptos"},{"ship_count":6,"x":-3.0,"y":-5.0,"owner":null,"name":"extos"}],"expeditions":[{"id":26,"ship_count":3,"origin":"protos","destination":"tritos","owner":2,"turns_remaining":7},{"id":23,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":2},{"id":27,"ship_count":3,"origin":"duteros","destination":"tritos","owner":2,"turns_remaining":3},{"id":24,"ship_count":2,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":3},{"id":29,"ship_count":4,"origin":"duteros","destination":"tritos","owner":2,"turns_remaining":5},{"id":28,"ship_count":2,"origin":"protos","destination":"tritos","owner":2,"turns_remaining":9}]}
|
||||
{"planets":[{"ship_count":4,"x":-6.0,"y":0.0,"owner":2,"name":"protos"},{"ship_count":4,"x":-3.0,"y":5.0,"owner":2,"name":"duteros"},{"ship_count":6,"x":3.0,"y":5.0,"owner":null,"name":"tritos"},{"ship_count":2,"x":6.0,"y":0.0,"owner":2,"name":"tetartos"},{"ship_count":6,"x":3.0,"y":-5.0,"owner":null,"name":"pemptos"},{"ship_count":6,"x":-3.0,"y":-5.0,"owner":null,"name":"extos"}],"expeditions":[{"id":26,"ship_count":3,"origin":"protos","destination":"tritos","owner":2,"turns_remaining":6},{"id":23,"ship_count":1,"origin":"protos","destination":"tetartos","owner":1,"turns_remaining":1},{"id":27,"ship_count":3,"origin":"duteros","destination":"tritos","owner":2,"turns_remaining":2},{"id":24,"ship_count":2,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":2},{"id":29,"ship_count":4,"origin":"duteros","destination":"tritos","owner":2,"turns_remaining":4},{"id":28,"ship_count":2,"origin":"protos","destination":"tritos","owner":2,"turns_remaining":8},{"id":30,"ship_count":4,"origin":"tetartos","destination":"tritos","owner":2,"turns_remaining":5}]}
|
||||
{"planets":[{"ship_count":2,"x":-6.0,"y":0.0,"owner":2,"name":"protos"},{"ship_count":5,"x":-3.0,"y":5.0,"owner":2,"name":"duteros"},{"ship_count":6,"x":3.0,"y":5.0,"owner":null,"name":"tritos"},{"ship_count":2,"x":6.0,"y":0.0,"owner":2,"name":"tetartos"},{"ship_count":6,"x":3.0,"y":-5.0,"owner":null,"name":"pemptos"},{"ship_count":6,"x":-3.0,"y":-5.0,"owner":null,"name":"extos"}],"expeditions":[{"id":26,"ship_count":3,"origin":"protos","destination":"tritos","owner":2,"turns_remaining":5},{"id":31,"ship_count":3,"origin":"protos","destination":"tritos","owner":2,"turns_remaining":10},{"id":27,"ship_count":3,"origin":"duteros","destination":"tritos","owner":2,"turns_remaining":1},{"id":24,"ship_count":2,"origin":"tetartos","destination":"protos","owner":2,"turns_remaining":1},{"id":29,"ship_count":4,"origin":"duteros","destination":"tritos","owner":2,"turns_remaining":3},{"id":28,"ship_count":2,"origin":"protos","destination":"tritos","owner":2,"turns_remaining":7},{"id":30,"ship_count":4,"origin":"tetartos","destination":"tritos","owner":2,"turns_remaining":4}]}
|
|
@ -3,18 +3,25 @@ extern crate serde;
|
|||
extern crate serde_derive;
|
||||
extern crate serde_json;
|
||||
|
||||
extern crate tokio;
|
||||
extern crate futures;
|
||||
extern crate mozaic;
|
||||
extern crate rand;
|
||||
extern crate tokio;
|
||||
|
||||
extern crate tracing;
|
||||
extern crate tracing_futures;
|
||||
extern crate tracing_subscriber;
|
||||
|
||||
use mozaic::errors;
|
||||
use mozaic::messaging::types::*;
|
||||
use std::env;
|
||||
use std::net::SocketAddr;
|
||||
use mozaic::messaging::types::*;
|
||||
use mozaic::errors;
|
||||
|
||||
use mozaic::modules::{Aggregator, Steplock, game};
|
||||
use tracing::{span, Level};
|
||||
use tracing_futures::Instrument;
|
||||
use tracing_subscriber::{fmt, EnvFilter};
|
||||
|
||||
use mozaic::modules::{game, Aggregator, Steplock};
|
||||
|
||||
mod planetwars;
|
||||
|
||||
|
@ -24,22 +31,31 @@ fn main() {
|
|||
let name = args[0].clone();
|
||||
match run(args) {
|
||||
None => print_info(&name),
|
||||
_ => {},
|
||||
_ => {}
|
||||
};
|
||||
}
|
||||
|
||||
use mozaic::runtime::{Broker};
|
||||
use rand::Rng;
|
||||
use errors::Consumable;
|
||||
use mozaic::modules::ConnectionManager;
|
||||
use mozaic::modules::util;
|
||||
use mozaic::modules::ConnectionManager;
|
||||
use mozaic::runtime::Broker;
|
||||
use rand::Rng;
|
||||
use std::collections::HashMap;
|
||||
|
||||
fn print_info(name: &str) {
|
||||
println!("Usage: {} map_location [number_of_clients [output [max_turns]]]", name);
|
||||
println!(
|
||||
"Usage: {} map_location [number_of_clients [output [max_turns]]]",
|
||||
name
|
||||
);
|
||||
}
|
||||
|
||||
pub fn run(args: Vec<String>) -> Option<()> {
|
||||
let subscriber = fmt::Subscriber::builder()
|
||||
.with_env_filter(EnvFilter::try_from_default_env().unwrap_or(EnvFilter::from("info")))
|
||||
.without_time()
|
||||
.inherit_fields(true)
|
||||
.finish();
|
||||
let _ = tracing::subscriber::set_global_default(subscriber);
|
||||
|
||||
let addr = "127.0.0.1:9142".parse::<SocketAddr>().unwrap();
|
||||
|
||||
|
@ -49,14 +65,26 @@ pub fn run(args : Vec<String>) -> Option<()> {
|
|||
let steplock_id: ReactorId = rand::thread_rng().gen();
|
||||
|
||||
let map = args.get(1)?;
|
||||
let number_of_clients = args.get(2).map(|x| x.parse().expect("Client number should be a number")).unwrap_or(1);
|
||||
let number_of_clients = args
|
||||
.get(2)
|
||||
.map(|x| x.parse().expect("Client number should be a number"))
|
||||
.unwrap_or(1);
|
||||
let location = args.get(3).map(|x| x.as_str()).unwrap_or("game.json");
|
||||
let max_turns = args.get(4).map(|x| x.parse().expect("Max turns should be a number")).unwrap_or(500);
|
||||
let max_turns = args
|
||||
.get(4)
|
||||
.map(|x| x.parse().expect("Max turns should be a number"))
|
||||
.unwrap_or(500);
|
||||
|
||||
let ids: HashMap<util::Identifier, util::PlayerId> = (0..number_of_clients).map(|x| (rand::thread_rng().gen::<u64>().into(), x.into())).collect();
|
||||
let ids: HashMap<util::Identifier, util::PlayerId> = (0..number_of_clients)
|
||||
.map(|x| (rand::thread_rng().gen::<u64>().into(), x.into()))
|
||||
.collect();
|
||||
|
||||
let config = planetwars::Config { map_file: map.to_string(), max_turns: max_turns };
|
||||
let game = planetwars::PlanetWarsGame::new(config.create_game(number_of_clients as usize), location);
|
||||
let config = planetwars::Config {
|
||||
map_file: map.to_string(),
|
||||
max_turns: max_turns,
|
||||
};
|
||||
let game =
|
||||
planetwars::PlanetWarsGame::new(config.create_game(number_of_clients as usize), location);
|
||||
|
||||
println!("Tokens:");
|
||||
let keys: Vec<u64> = ids.keys().map(|&x| x.into()).collect();
|
||||
|
@ -65,19 +93,48 @@ pub fn run(args : Vec<String>) -> Option<()> {
|
|||
}
|
||||
|
||||
tokio::run(futures::lazy(move || {
|
||||
mozaic::graph::set_graph(mozaic::graph::Graph::new());
|
||||
let mut broker = Broker::new().unwrap();
|
||||
|
||||
broker.spawn(welcomer_id.clone(), game::GameReactor::params(steplock_id.clone(), Box::new(game)), "Main").display();
|
||||
broker.spawn(steplock_id.clone(), Steplock::new(broker.clone(), ids.values().cloned().collect(), welcomer_id.clone(), aggregator_id.clone()).with_timeout(5000).params(), "Steplock").display();
|
||||
broker.spawn(aggregator_id.clone(), Aggregator::params(manager_id.clone(), steplock_id.clone()), "Aggregator").display();
|
||||
broker.spawn(
|
||||
broker
|
||||
.spawn(
|
||||
welcomer_id.clone(),
|
||||
game::GameReactor::params(steplock_id.clone(), Box::new(game)),
|
||||
"Main",
|
||||
)
|
||||
.display();
|
||||
broker
|
||||
.spawn(
|
||||
steplock_id.clone(),
|
||||
Steplock::new(
|
||||
broker.clone(),
|
||||
ids.values().cloned().collect(),
|
||||
welcomer_id.clone(),
|
||||
aggregator_id.clone(),
|
||||
)
|
||||
.with_timeout(5000)
|
||||
.params(),
|
||||
"Steplock",
|
||||
)
|
||||
.display();
|
||||
broker
|
||||
.spawn(
|
||||
aggregator_id.clone(),
|
||||
Aggregator::params(manager_id.clone(), steplock_id.clone()),
|
||||
"Aggregator",
|
||||
)
|
||||
.display();
|
||||
broker
|
||||
.spawn(
|
||||
manager_id.clone(),
|
||||
ConnectionManager::params(broker.clone(), ids, aggregator_id.clone(), addr),
|
||||
"Connection Manager"
|
||||
).display();
|
||||
"Connection Manager",
|
||||
)
|
||||
.display();
|
||||
|
||||
Ok(())
|
||||
}));
|
||||
}).instrument(span!(Level::TRACE, "main")),
|
||||
);
|
||||
|
||||
Some(())
|
||||
}
|
||||
|
|
|
@ -53,6 +53,7 @@ impl PlanetWarsGame {
|
|||
);
|
||||
|
||||
if !player.alive || self.state.is_finished() {
|
||||
println!("Kicking player {}", player.id);
|
||||
updates.push(game::Update::Kick((player.id as u64).into()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
extern crate mozaic;
|
||||
extern crate tokio;
|
||||
extern crate futures;
|
||||
extern crate capnp;
|
||||
extern crate futures;
|
||||
extern crate mozaic;
|
||||
extern crate rand;
|
||||
extern crate tokio;
|
||||
|
||||
extern crate serde;
|
||||
#[macro_use]
|
||||
|
@ -11,26 +11,30 @@ extern crate serde_json;
|
|||
|
||||
use rand::Rng;
|
||||
|
||||
use mozaic::core_capnp::{initialize, terminate_stream, identify, actor_joined};
|
||||
use mozaic::base_capnp::{client_message, host_message};
|
||||
use mozaic::cmd_capnp::{bot_input, bot_return};
|
||||
use mozaic::connection_capnp::client_kicked;
|
||||
use mozaic::core_capnp::{actor_joined, identify, initialize, terminate_stream};
|
||||
use mozaic::errors::*;
|
||||
use mozaic::messaging::reactor::*;
|
||||
use mozaic::messaging::types::*;
|
||||
use mozaic::errors::*;
|
||||
use mozaic::base_capnp::{client_message, host_message};
|
||||
use mozaic::connection_capnp::client_kicked;
|
||||
use mozaic::cmd_capnp::{bot_input, bot_return};
|
||||
use mozaic::runtime::{Broker, BrokerHandle};
|
||||
use mozaic::modules::BotReactor;
|
||||
use mozaic::runtime;
|
||||
use mozaic::modules::{BotReactor};
|
||||
use mozaic::runtime::{Broker, BrokerHandle};
|
||||
|
||||
use std::env;
|
||||
use std::str;
|
||||
use std::process;
|
||||
|
||||
mod types;
|
||||
|
||||
fn main() {
|
||||
let args: Vec<String> = env::args().collect();
|
||||
let id = args.get(1).unwrap().parse().unwrap();
|
||||
let client_args = args.get(2..).expect("How do you expect me to spawn your bot?").to_vec();
|
||||
let client_args = args
|
||||
.get(2..)
|
||||
.expect("How do you expect me to spawn your bot?")
|
||||
.to_vec();
|
||||
|
||||
let addr = "127.0.0.1:9142".parse().unwrap();
|
||||
let self_id: ReactorId = rand::thread_rng().gen();
|
||||
|
@ -43,7 +47,9 @@ fn main() {
|
|||
broker: broker.clone(),
|
||||
args: client_args,
|
||||
};
|
||||
broker.spawn(self_id.clone(), reactor.params(), "main").display();
|
||||
broker
|
||||
.spawn(self_id.clone(), reactor.params(), "main")
|
||||
.display();
|
||||
|
||||
tokio::spawn(runtime::connect_to_server(broker, self_id, &addr));
|
||||
Ok(())
|
||||
|
@ -74,8 +80,7 @@ impl ClientReactor {
|
|||
&mut self,
|
||||
handle: &mut ReactorHandle<C>,
|
||||
_: initialize::Reader,
|
||||
) -> Result<()>
|
||||
{
|
||||
) -> Result<()> {
|
||||
// open link with runtime, for communicating with chat GUI
|
||||
let runtime_link = RuntimeLink::params(handle.id().clone());
|
||||
handle.open_link(runtime_link)?;
|
||||
|
@ -92,13 +97,12 @@ impl ClientReactor {
|
|||
&mut self,
|
||||
handle: &mut ReactorHandle<C>,
|
||||
r: actor_joined::Reader,
|
||||
) -> Result<()>
|
||||
{
|
||||
) -> Result<()> {
|
||||
let id = r.get_id()?;
|
||||
|
||||
if let Some(server) = &self.server {
|
||||
handle.open_link(HostLink::params(ReactorId::from(id)))?;
|
||||
self.broker.register_as(id.into(), server.clone());
|
||||
self.broker.register_as(id.into(), server.clone(), "Server");
|
||||
|
||||
// Fake bot msg
|
||||
let mut chat_message = MsgBuffer::<bot_return::Owned>::new();
|
||||
|
@ -106,9 +110,7 @@ impl ClientReactor {
|
|||
b.set_message(b"");
|
||||
});
|
||||
handle.send_internal(chat_message)?;
|
||||
|
||||
} else {
|
||||
|
||||
handle.open_link(ServerLink::params(id.into()))?;
|
||||
self.server = Some(id.into());
|
||||
|
||||
|
@ -117,20 +119,28 @@ impl ClientReactor {
|
|||
b.set_key(self.id);
|
||||
});
|
||||
handle.send_internal(identify).display();
|
||||
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for ClientReactor {
|
||||
fn drop(&mut self) {
|
||||
println!("Client reactor dropped");
|
||||
}
|
||||
}
|
||||
|
||||
// Handler for the connection with the chat server
|
||||
struct ServerLink;
|
||||
impl ServerLink {
|
||||
fn params<C: Ctx>(foreign_id: ReactorId) -> LinkParams<Self, C> {
|
||||
let mut params = LinkParams::new(foreign_id, Self);
|
||||
|
||||
params.external_handler( terminate_stream::Owned, CtxHandler::new(Self::close_handler) );
|
||||
params.external_handler(
|
||||
terminate_stream::Owned,
|
||||
CtxHandler::new(Self::close_handler),
|
||||
);
|
||||
params.external_handler(actor_joined::Owned, CtxHandler::new(actor_joined::e_to_i));
|
||||
|
||||
params.internal_handler(identify::Owned, CtxHandler::new(Self::identify));
|
||||
|
@ -138,11 +148,7 @@ impl ServerLink {
|
|||
return params;
|
||||
}
|
||||
|
||||
fn identify<C: Ctx>(
|
||||
&mut self,
|
||||
handle: &mut LinkHandle<C>,
|
||||
id: identify::Reader,
|
||||
) -> Result<()> {
|
||||
fn identify<C: Ctx>(&mut self, handle: &mut LinkHandle<C>, id: identify::Reader) -> Result<()> {
|
||||
let id = id.get_key();
|
||||
|
||||
let mut chat_message = MsgBuffer::<identify::Owned>::new();
|
||||
|
@ -158,8 +164,7 @@ impl ServerLink {
|
|||
&mut self,
|
||||
handle: &mut LinkHandle<C>,
|
||||
_: terminate_stream::Reader,
|
||||
) -> Result<()>
|
||||
{
|
||||
) -> Result<()> {
|
||||
// also close our end of the stream
|
||||
handle.close_link()?;
|
||||
return Ok(());
|
||||
|
@ -176,15 +181,9 @@ impl HostLink {
|
|||
CtxHandler::new(Self::receive_host_message),
|
||||
);
|
||||
|
||||
params.internal_handler(
|
||||
bot_return::Owned,
|
||||
CtxHandler::new(Self::send_chat_message),
|
||||
);
|
||||
params.internal_handler(bot_return::Owned, CtxHandler::new(Self::send_chat_message));
|
||||
|
||||
params.external_handler(
|
||||
client_kicked::Owned,
|
||||
CtxHandler::new(Self::client_kicked),
|
||||
);
|
||||
params.external_handler(client_kicked::Owned, CtxHandler::new(client_kicked::e_to_i));
|
||||
|
||||
return params;
|
||||
}
|
||||
|
@ -195,8 +194,7 @@ impl HostLink {
|
|||
&mut self,
|
||||
handle: &mut LinkHandle<C>,
|
||||
send_message: bot_return::Reader,
|
||||
) -> Result<()>
|
||||
{
|
||||
) -> Result<()> {
|
||||
let message = send_message.get_message()?;
|
||||
|
||||
println!("Our bot sent");
|
||||
|
@ -212,29 +210,13 @@ impl HostLink {
|
|||
return Ok(());
|
||||
}
|
||||
|
||||
// pick up a 'send_message' event from the reactor, and put it to effect
|
||||
// by constructing the chat message and sending it to the chat server.
|
||||
fn client_kicked<C: Ctx>(
|
||||
&mut self,
|
||||
handle: &mut LinkHandle<C>,
|
||||
_: client_kicked::Reader,
|
||||
) -> Result<()>
|
||||
{
|
||||
// Disconnect
|
||||
|
||||
handle.close_link()?;
|
||||
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
// receive a chat message from the chat server, and broadcast it on the
|
||||
// reactor.
|
||||
fn receive_host_message<C: Ctx>(
|
||||
&mut self,
|
||||
handle: &mut LinkHandle<C>,
|
||||
host_message: host_message::Reader,
|
||||
) -> Result<()>
|
||||
{
|
||||
) -> Result<()> {
|
||||
let message = host_message.get_data()?;
|
||||
|
||||
let message: types::ServerMessage = serde_json::from_slice(message).unwrap();
|
||||
|
@ -249,10 +231,11 @@ impl HostLink {
|
|||
b.set_input(&serde_json::to_vec(&state).unwrap());
|
||||
});
|
||||
handle.send_internal(bot_msg).display();
|
||||
},
|
||||
}
|
||||
types::ServerMessage::FinalState(state) => {
|
||||
println!("Game finished with");
|
||||
println!("{:?}", state);
|
||||
process::exit(0);
|
||||
}
|
||||
types::ServerMessage::PlayerAction(action) => {
|
||||
println!("Out bot did");
|
||||
|
@ -271,9 +254,21 @@ impl BotLink {
|
|||
|
||||
params.external_handler(bot_return::Owned, CtxHandler::new(bot_return::e_to_i));
|
||||
params.internal_handler(bot_input::Owned, CtxHandler::new(bot_input::i_to_e));
|
||||
|
||||
params.internal_handler(client_kicked::Owned, CtxHandler::new(Self::close));
|
||||
return params;
|
||||
}
|
||||
|
||||
// pick up a 'send_message' event from the reactor, and put it to effect
|
||||
// by constructing the chat message and sending it to the chat server.
|
||||
fn close<C: Ctx>(
|
||||
&mut self,
|
||||
handle: &mut LinkHandle<C>,
|
||||
_: client_kicked::Reader,
|
||||
) -> Result<()> {
|
||||
handle.close_link()?;
|
||||
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
|
||||
struct RuntimeLink;
|
||||
|
@ -281,11 +276,20 @@ impl RuntimeLink {
|
|||
fn params<C: Ctx>(foreign_id: ReactorId) -> LinkParams<Self, C> {
|
||||
let mut params = LinkParams::new(foreign_id, Self);
|
||||
|
||||
params.external_handler(
|
||||
actor_joined::Owned,
|
||||
CtxHandler::new(actor_joined::e_to_i),
|
||||
);
|
||||
|
||||
params.external_handler(actor_joined::Owned, CtxHandler::new(actor_joined::e_to_i));
|
||||
params.internal_handler(client_kicked::Owned, CtxHandler::new(Self::close));
|
||||
return params;
|
||||
}
|
||||
|
||||
// pick up a 'send_message' event from the reactor, and put it to effect
|
||||
// by constructing the chat message and sending it to the chat server.
|
||||
fn close<C: Ctx>(
|
||||
&mut self,
|
||||
handle: &mut LinkHandle<C>,
|
||||
_: client_kicked::Reader,
|
||||
) -> Result<()> {
|
||||
handle.close_link()?;
|
||||
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue