diff options
author | Tor Andersson <tor@ccxvii.net> | 2023-07-17 12:32:30 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-07-18 12:48:59 +0200 |
commit | c2cc252649615b9acaf0f0512bafebb719b71d6d (patch) | |
tree | 5820c81f3ca0e89bc984f999e8855831ba3a31c3 | |
parent | 8d6138c0761e973c532e4c42c773e136c91e21af (diff) | |
download | field-cloth-gold-c2cc252649615b9acaf0f0512bafebb719b71d6d.tar.gz |
WIP multiple tiles in one click
-rw-r--r-- | rules.js | 54 |
1 files changed, 45 insertions, 9 deletions
@@ -426,6 +426,42 @@ function remove_tile_from_rival_court(tile) { array_remove_item(rival_court(), tile) } +function reveal_tiles_into_court(tile) { + let hand = own_hand() + let court = own_court() + tile = tile_type(tile) + for (let i = 0; i < hand.length; ) { + if (tile_type(hand[i]) === tile) { + court.push(hand[i]) + array_remove(hand, i) + } else { + ++i + } + } +} + +function remove_tiles_from_court(tile) { + tile = tile_type(tile) + let court = own_court() + for (let i = 0; i < court.length; ) { + if (tile_type(court[i]) === tile) + array_remove(court, i) + else + ++i + } +} + +function remove_tiles_from_rival_court(tile) { + tile = tile_type(tile) + let court = rival_court() + for (let i = 0; i < court.length; ) { + if (tile_type(court[i]) === tile) + array_remove(court, i) + else + ++i + } +} + // === FLOW OF PLAY === states.move_token = { @@ -682,7 +718,7 @@ states.cloth_of_gold_reveal = { gen_reveal_tiles_into_court(TILE_GOLD) }, tile(tile) { - reveal_tile_into_court(tile) + reveal_tiles_into_court(tile) if (!can_reveal_tiles_into_court(TILE_GOLD)) goto_cloth_of_gold_score() }, @@ -743,7 +779,7 @@ states.banquets_and_feasts_reveal = { gen_reveal_tiles_into_court(TILE_BLUE) }, tile(tile) { - reveal_tile_into_court(tile) + reveal_tiles_into_court(tile) if (!can_reveal_tiles_into_court(TILE_BLUE)) goto_banquets_and_feasts_score() }, @@ -770,7 +806,7 @@ states.banquets_and_feasts_remove = { gen_remove_tiles_from_court(TILE_BLUE) }, tile(tile) { - remove_tile_from_court(tile) + remove_tiles_from_court(tile) if (!can_remove_tiles_from_court(TILE_BLUE)) end_turn() }, @@ -812,7 +848,7 @@ states.godliness_and_piety_reveal = { gen_reveal_tiles_into_court(TILE_WHITE) }, tile(tile) { - reveal_tile_into_court(tile) + reveal_tiles_into_court(tile) if (!can_reveal_tiles_into_court(TILE_WHITE)) goto_godliness_and_piety_score() }, @@ -840,7 +876,7 @@ states.godliness_and_piety_remove = { gen_remove_tiles_from_court(TILE_WHITE) }, tile(tile) { - remove_tile_from_court(tile) + remove_tiles_from_court(tile) if (!can_remove_tiles_from_court(TILE_WHITE)) end_turn() }, @@ -901,7 +937,7 @@ states.tournaments_reveal = { gen_reveal_tiles_into_court(TILE_RED) }, tile(tile) { - reveal_tile_into_court(tile) + reveal_tiles_into_court(tile) if (!can_reveal_tiles_into_court(TILE_RED)) goto_tournaments_score_own() }, @@ -929,7 +965,7 @@ states.tournaments_remove_own = { gen_remove_tiles_from_court(TILE_RED) }, tile(tile) { - remove_tile_from_court(tile) + remove_tiles_from_court(tile) if (!can_remove_tiles_from_court(TILE_RED)) goto_tournaments_score_rival() }, @@ -956,7 +992,7 @@ states.tournaments_remove_rival = { gen_remove_tiles_from_rival_courts(TILE_RED) }, tile(tile) { - remove_tile_from_rival_court(tile) + remove_tiles_from_rival_court(tile) if (!can_remove_tiles_from_rival_court(TILE_RED)) game.state = "tournaments_secrecy" }, @@ -1013,7 +1049,7 @@ states.collections_reveal = { gen_action_tile(tile) }, tile(tile) { - reveal_tile_into_court(tile) + reveal_tiles_into_court(tile) if (own_hand().length === 0) goto_collections_score() }, |