diff options
author | Tor Andersson <tor@ccxvii.net> | 2023-04-15 00:12:56 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-05-03 18:48:16 +0200 |
commit | 6ba5efef9af79669e6f784d2b6b913ecac939e99 (patch) | |
tree | 7fc8eeefcf954ecc21fd0079c0a340de2b7be044 | |
parent | d195265a93d05a8466355c54ac4d211714d75014 (diff) | |
download | andean-abyss-6ba5efef9af79669e6f784d2b6b913ecac939e99.tar.gz |
Always place first available piece for smoother animations.
-rw-r--r-- | rules.js | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -499,6 +499,28 @@ function set_piece_space(p, s) { game.pieces[p] = s } +function piece_type(p) { + if (p >= first_piece[GOVT][TROOPS] && p <= last_piece[GOVT][TROOPS]) + return TROOPS + if (p >= first_piece[GOVT][POLICE] && p <= last_piece[GOVT][POLICE]) + return POLICE + if (p >= first_piece[GOVT][BASE] && p <= last_piece[GOVT][BASE]) + return BASE + if (p >= first_piece[FARC][GUERRILLA] && p <= last_piece[FARC][GUERRILLA]) + return GUERRILLA + if (p >= first_piece[FARC][BASE] && p <= last_piece[FARC][BASE]) + return BASE + if (p >= first_piece[AUC][GUERRILLA] && p <= last_piece[AUC][GUERRILLA]) + return GUERRILLA + if (p >= first_piece[AUC][BASE] && p <= last_piece[AUC][BASE]) + return BASE + if (p >= first_piece[CARTELS][GUERRILLA] && p <= last_piece[CARTELS][GUERRILLA]) + return GUERRILLA + if (p >= first_piece[CARTELS][BASE] && p <= last_piece[CARTELS][BASE]) + return BASE + throw "IMPOSSIBLE" +} + function piece_faction(p) { if (p >= first_piece[GOVT][TROOPS] && p <= last_piece[GOVT][TROOPS]) return GOVT @@ -1205,6 +1227,8 @@ function move_piece(p, s) { } function place_piece(p, s) { + if (piece_space(p) === AVAILABLE) + p = find_piece(AVAILABLE, piece_faction(p), piece_type(p)) log(`Placed ${piece_name(p)} in S${s}.`) set_underground(p) set_piece_space(p, s) |