diff options
author | Frans Bongers <fransbongers@franss-mbp.home> | 2024-12-16 21:27:53 +0100 |
---|---|---|
committer | Frans Bongers <fransbongers@franss-mbp.home> | 2024-12-16 21:27:53 +0100 |
commit | b80ba3e739ed5dd1fa2796e3683bbe98659d865a (patch) | |
tree | d0a07b4e152ee7d50eb42ea411db424254406d5c /rules.ts | |
parent | 9704b9f460e37ba6e461f06def50f4fec76f8fef (diff) | |
download | land-and-freedom-b80ba3e739ed5dd1fa2796e3683bbe98659d865a.tar.gz |
determine government track direction
Diffstat (limited to 'rules.ts')
-rw-r--r-- | rules.ts | 35 |
1 files changed, 33 insertions, 2 deletions
@@ -52,6 +52,8 @@ import data, { DEFEAT, FRONTS, create_effect, + AWAY_FROM_CENTER, + TOWARDS_CENTER, // StaticData, // PLAYER_WITH_MOST_HERO_POINTS, } from './data'; @@ -847,13 +849,28 @@ states.move_track = { const node = get_active_node(); const track = node.a.t; const value = node.a.v; - view.prompt = `Move ${tracks[track].name} ${value > 0 ? 'up' : 'down'}`; + const name = tracks[track].name; + + view.prompt = `Move ${name} ${value > 0 ? 'up' : 'down'}`; + if (track === GOVERNMENT && value === TOWARDS_CENTER) { + view.prompt = `Move ${name} towards center`; + } else if (track === GOVERNMENT && value === AWAY_FROM_CENTER) { + view.prompt = `Move ${name} away from center`; + } // return 'Decrease ' + tracks[effect.target].name; gen_action_standee(track); }, standee(s: number) { const node = get_active_node(); - const value = node.a.v; + let value = node.a.v; + + if ( + s === GOVERNMENT && + (value === TOWARDS_CENTER || value === AWAY_FROM_CENTER) + ) { + value = get_government_track_direction(value); + } + move_track(s, value); resolve_active_and_proceed(); }, @@ -1191,6 +1208,20 @@ function get_min_value_for_track(track_id: number) { } } +// TOWARDS_CENTER = 10; +// AWAY_FROM_CENTER = 11; +function get_government_track_direction(direction: 10 | 11): -1 | 1 { + const value = game.tracks[GOVERNMENT]; + if ( + (direction === TOWARDS_CENTER && value >= 6) || + (direction === AWAY_FROM_CENTER && value <= 5) + ) { + return -1; + } else { + return 1; + } +} + function move_track(track_id: number, change: number) { const current_value = game.tracks[track_id]; let new_value = current_value + change; |