Skip to content

Commit fe514a2

Browse files
committed
Display how many knights each player has played if that number is non-zero
1 parent 67e448a commit fe514a2

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

client.sunder

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,26 +1407,31 @@ func client_update(cstate: *client_state, sender: *message_sender[[client_messag
14071407
var victory_points: sint = uninit;
14081408
var resources: sint = uninit;
14091409
var dev_cards: sint = uninit;
1410+
var knights_played: sint = uninit;
14101411
switch player {
14111412
::player::RED {
14121413
victory_points = cstate.*.r.victory_points;
14131414
resources = cstate.*.r.resources;
14141415
dev_cards = cstate.*.r.dev_cards;
1416+
knights_played = cstate.*.r.knights_played;
14151417
}
14161418
::player::BLUE {
14171419
victory_points = cstate.*.b.victory_points;
14181420
resources = cstate.*.b.resources;
14191421
dev_cards = cstate.*.b.dev_cards;
1422+
knights_played = cstate.*.b.knights_played;
14201423
}
14211424
::player::WHITE {
14221425
victory_points = cstate.*.w.victory_points;
14231426
resources = cstate.*.w.resources;
14241427
dev_cards = cstate.*.w.dev_cards;
1428+
knights_played = cstate.*.w.knights_played;
14251429
}
14261430
::player::ORANGE {
14271431
victory_points = cstate.*.o.victory_points;
14281432
resources = cstate.*.o.resources;
14291433
dev_cards = cstate.*.o.dev_cards;
1434+
knights_played = cstate.*.o.knights_played;
14301435
}
14311436
}
14321437

@@ -1472,6 +1477,14 @@ func client_update(cstate: *client_state, sender: *message_sender[[client_messag
14721477
(:[]std::formatter)[
14731478
std::formatter::init[[sint]](&dev_cards)]);
14741479
defer s.fini();
1480+
if knights_played != 0 {
1481+
var w = std::writer::init[[typeof(s)]](&s);
1482+
std::print_format(
1483+
w,
1484+
" ({} knights played)",
1485+
(:[]std::formatter)[
1486+
std::formatter::init[[sint]](&knights_played)]);
1487+
}
14751488
cstate.*.ui.text(s.data());
14761489

14771490
if cstate.*.player.is_value() and cstate.*.player.value() == player {

server.sunder

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2148,6 +2148,7 @@ func server_update(sstate: *server_state) void {
21482148
.victory_points = sstate.*.public_victory_points(player::RED),
21492149
.resources = sstate.*.r_info.resource_count(),
21502150
.dev_cards = sstate.*.r_info.unused_dev_card_count(),
2151+
.knights_played = sstate.*.r_info.knights_played_count(),
21512152
.discarded = sstate.*.r_discarded,
21522153
.trade_submitted = sstate.*.r_trade_submitted,
21532154
};
@@ -2157,6 +2158,7 @@ func server_update(sstate: *server_state) void {
21572158
.victory_points = sstate.*.public_victory_points(player::BLUE),
21582159
.resources = sstate.*.b_info.resource_count(),
21592160
.dev_cards = sstate.*.b_info.unused_dev_card_count(),
2161+
.knights_played = sstate.*.b_info.knights_played_count(),
21602162
.discarded = sstate.*.b_discarded,
21612163
.trade_submitted = sstate.*.b_trade_submitted,
21622164
};
@@ -2166,6 +2168,7 @@ func server_update(sstate: *server_state) void {
21662168
.victory_points = sstate.*.public_victory_points(player::WHITE),
21672169
.resources = sstate.*.w_info.resource_count(),
21682170
.dev_cards = sstate.*.w_info.unused_dev_card_count(),
2171+
.knights_played = sstate.*.w_info.knights_played_count(),
21692172
.discarded = sstate.*.w_discarded,
21702173
.trade_submitted = sstate.*.w_trade_submitted,
21712174
};
@@ -2175,6 +2178,7 @@ func server_update(sstate: *server_state) void {
21752178
.victory_points = sstate.*.public_victory_points(player::ORANGE),
21762179
.resources = sstate.*.o_info.resource_count(),
21772180
.dev_cards = sstate.*.o_info.unused_dev_card_count(),
2181+
.knights_played = sstate.*.o_info.knights_played_count(),
21782182
.discarded = sstate.*.o_discarded,
21792183
.trade_submitted = sstate.*.o_trade_submitted,
21802184
};

shared.sunder

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1610,6 +1610,14 @@ struct hidden_player_info {
16101610
}
16111611
return count;
16121612
}
1613+
1614+
func knights_played_count(self: *hidden_player_info) sint {
1615+
var count: sint = 0;
1616+
for i in self.*.dev_card_count {
1617+
count += (:sint)(self.*.dev_card_array[i].kind == dev_card::KNIGHT and self.*.dev_card_array[i].used);
1618+
}
1619+
return count;
1620+
}
16131621
}
16141622

16151623
struct public_player_info {
@@ -1618,6 +1626,7 @@ struct public_player_info {
16181626
var victory_points: sint;
16191627
var resources: sint;
16201628
var dev_cards: sint;
1629+
var knights_played: sint;
16211630
var discarded: bool;
16221631
var trade_submitted: bool;
16231632

@@ -1628,6 +1637,7 @@ struct public_player_info {
16281637
self.victory_points = xstr_to_int[[sint]](value.*.map_xlookup_str("victory-points").*.str());
16291638
self.resources = xstr_to_int[[sint]](value.*.map_xlookup_str("resources").*.str());
16301639
self.dev_cards = xstr_to_int[[sint]](value.*.map_xlookup_str("dev-cards").*.str());
1640+
self.knights_played = xstr_to_int[[sint]](value.*.map_xlookup_str("knights-played").*.str());
16311641
self.discarded = xstr_to_bool(value.*.map_xlookup_str("discarded").*.str());
16321642
self.trade_submitted = xstr_to_bool(value.*.map_xlookup_str("trade-submitted").*.str());
16331643
return self;
@@ -1640,6 +1650,7 @@ struct public_player_info {
16401650
out.map_insert_str("victory-points", int_to_bubby[[sint]](self.*.victory_points));
16411651
out.map_insert_str("resources", int_to_bubby[[sint]](self.*.resources));
16421652
out.map_insert_str("dev-cards", int_to_bubby[[sint]](self.*.dev_cards));
1653+
out.map_insert_str("knights-played", int_to_bubby[[sint]](self.*.knights_played));
16431654
out.map_insert_str("discarded", bool_to_bubby(self.*.discarded));
16441655
out.map_insert_str("trade-submitted", bool_to_bubby(self.*.trade_submitted));
16451656
return out;

0 commit comments

Comments
 (0)