Skip to content

Commit

Permalink
Add brilliant evasion
Browse files Browse the repository at this point in the history
  • Loading branch information
punkUser committed Nov 10, 2018
1 parent eb66c3e commit 8bfd8c9
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 13 deletions.
1 change: 1 addition & 0 deletions deploy.sh
@@ -1,3 +1,4 @@
#!/bin/bash
dub build -b release
scp xwing_math punkuser@xwing.gateofstorms.net:~/xwing_math/xwing_math_update
rsync -av public/ punkuser@xwing.gateofstorms.net:~/xwing_math/public/
8 changes: 7 additions & 1 deletion source/defense_form.d
Expand Up @@ -43,7 +43,13 @@ align(1) struct DefenseForm

// Used by the shots to die form, but convenient to use the same defense form, albeit a subset
uint, "ship_hull", 5, // 0..31
uint, "ship_shields", 5, // 0..31, currently unused
uint, "ship_shields", 5, // 0..31
));

mixin(bitfields!(
bool, "brilliant_evasion", 1,

uint, "", 7,
));

static DefenseForm defaults()
Expand Down
16 changes: 13 additions & 3 deletions source/modify_defense_dice.d
Expand Up @@ -270,8 +270,10 @@ private SimulationState spend_focus_calculate_force(
if (focus_results_to_change > 0)
{
bool ezra_available = setup.defense.ezra_pilot && state.defense_tokens.stress > 0 && state.defense_tokens.force > 0;
bool brilliant_evasion_available = setup.defense.brilliant_evasion && state.defense_tokens.force > 0;

bool force_calculate_available = (state.defense_tokens.calculate + state.defense_tokens.force) > 0;
int change_with_one_token_count = ezra_available ? 2 : (force_calculate_available > 0 ? 1 : 0);
int change_with_one_token_count = (ezra_available || brilliant_evasion_available) ? 2 : (force_calculate_available > 0 ? 1 : 0);

if (state.defense_tokens.focus > 0 && (focus_results_to_change > change_with_one_token_count))
{
Expand All @@ -281,13 +283,21 @@ private SimulationState spend_focus_calculate_force(
}
else
{
if (ezra_available && focus_results_to_change > 1)
// NOTE: Have to re-check token counts and dice here for each effect we apply
if (ezra_available && focus_results_to_change > 1 && state.defense_tokens.force > 0)
{
state.defense_dice.change_dice(DieResult.Focus, DieResult.Evade, 2);
state.defense_tokens.force = state.defense_tokens.force - 1;
focus_results_to_change -= 2;
}
if (brilliant_evasion_available && focus_results_to_change > 1 && state.defense_tokens.force > 0)
{
state.defense_dice.change_dice(DieResult.Focus, DieResult.Hit, 2);
state.defense_dice.change_dice(DieResult.Focus, DieResult.Evade, 2);
state.defense_tokens.force = state.defense_tokens.force - 1;
focus_results_to_change -= 2;
}

// Regular force/calculate effect
if (prefer_spend_calculate)
{
state.defense_tokens.calculate = state.defense_tokens.calculate - state.defense_dice.change_dice(DieResult.Focus, DieResult.Hit, state.defense_tokens.calculate);
Expand Down
2 changes: 2 additions & 0 deletions source/simulation_setup2.d
Expand Up @@ -67,6 +67,7 @@ public class SimulationSetup
bool scum_lando_crew = false;
bool rebel_millennium_falcon = false; // 1 reroll if evading
bool heroic = false;
bool brilliant_evasion = false;

bool zeb_pilot = false;
bool leebo_pilot = false;
Expand Down Expand Up @@ -151,6 +152,7 @@ public SimulationSetup to_simulation_setup2(ref const(AttackForm) attack, ref co
setup.defense.scum_lando_crew = defense.scum_lando_crew;
setup.defense.rebel_millennium_falcon = defense.rebel_millennium_falcon;
setup.defense.heroic = defense.heroic;
setup.defense.brilliant_evasion = defense.brilliant_evasion;

return setup;
}
Expand Down
19 changes: 10 additions & 9 deletions source/views/defense_form.inc.dt
Expand Up @@ -57,19 +57,20 @@
- switch_control_t!("iden", form_name)("Iden Versio");
- switch_control_t!("selfless", form_name)("Selfless");
- switch_control_t!("serissu", form_name)("Serissu");

fieldset.fieldset
legend Talents
- switch_control_t!("elusive", form_name)("Elusive");
- switch_control_t!("heroic", form_name)("Heroic");
- switch_control_t!("lone_wolf", form_name)("Lone Wolf");
legend Talents and Powers
- switch_control_t!("brilliant_evasion", form_name)("Brilliant Evasion");
- switch_control_t!("elusive", form_name)("Elusive");
- switch_control_t!("heroic", form_name)("Heroic");
- switch_control_t!("lone_wolf", form_name)("Lone Wolf");

fieldset.fieldset
legend Crew and Gunners
- switch_control_t!("c3p0", form_name)("C-3P0 (guess 1)");
- switch_control_t!("finn_gunner", form_name)("Finn");
- switch_control_t!("l337", form_name)("L3-37");
- switch_control_t!("scum_lando_crew", form_name)("Lando Calrissian (Scum)");
- switch_control_t!("c3p0", form_name)("C-3P0 (guess 1)");
- switch_control_t!("finn_gunner", form_name)("Finn");
- switch_control_t!("l337", form_name)("L3-37");
- switch_control_t!("scum_lando_crew", form_name)("Lando Calrissian (Scum)");

fieldset.fieldset
legend Modifications and Titles
Expand Down

0 comments on commit 8bfd8c9

Please sign in to comment.