*label spend_insight_choices
*if (boxing_insights_unspent = 0)
    *bug This should not be reachable with 0 boxing insights
*temp stop_spending_insights false
*gosub check_whether_can_spend_insight
*if (can_spend_insight)
    You've gained insight into boxing: the tells, the pauses, the intentions.

    You notice your own patterns, enough to know what could be better. Some of your boxing techniques feel like they're ready. Ready for you to take them further.

    *if ((tutorial_mode) and (not(tutorial_boxing_insights_explained)))
        *set tutorial_boxing_insights_explained true
        At the end of each month, you can crystallise any [i]Boxing Insights[/i] into a new technique, or a stronger version of an existing move. Now's your chance.

    *goto spend_another_insight

*else
    *goto insights_not_ready

*label spend_another_insight
*gosub choose_where_to_spend_insight

*if (stop_spending_insights)
    *goto finish_spending_insights

*gosub check_whether_can_spend_insight

*if ((boxing_insights_unspent > 0) and (can_spend_insight))
    Insight, crystallised. But another technique presents itself.

    *goto spend_another_insight
*elseif (boxing_insights_unspent > 0)
    *goto insights_not_ready

*goto finish_spending_insights

*label insights_not_ready
*if (boxing_insights_unspent = 1)
    You carry one unspent [i]Boxing Insight[/i].
*else
    You carry ${boxing_insights_unspent} unspent [i]Boxing Insights[/i].

But none of your techniques are ready to absorb it. It lingers. A lesson, waiting to take shape.

*goto finish_spending_insights

*label finish_spending_insights
*page_break
*return

*label check_whether_can_spend_insight
*set can_spend_insight false
*set jab_upgradeable false
*set flurry_upgradeable false
*set combo_upgradeable false
*set block_upgradeable false
*set dodge_upgradeable false
*set counter_upgradeable false
*if (jab_level = 0)
    *if (stat_technique >= 18)
        *set jab_upgradeable true
        *set can_spend_insight true
*elseif (jab_level = 1)
    *if (stat_technique >= 32)
        *set jab_upgradeable true
        *set can_spend_insight true
*if (flurry_level = 0)
    *if ((stat_power >= 15) and (stat_toughness >= 15))
        *set flurry_upgradeable true
        *set can_spend_insight true
*elseif (flurry_level = 1)
    *if ((stat_power >= 24) and (stat_toughness >= 24))
        *set flurry_upgradeable true
        *set can_spend_insight true
*if (combo_level = 0)
    *if ((stat_technique >= 15) and (stat_power >= 15))
        *set combo_upgradeable true
        *set can_spend_insight true
*elseif (combo_level = 1)
    *if ((stat_technique >= 24) and (stat_power >= 24))
        *set combo_upgradeable true
        *set can_spend_insight true
*if (block_level = 0)
    *if (stat_toughness >= 18)
        *set block_upgradeable true
        *set can_spend_insight true
*elseif (block_level = 1)
    *if (stat_toughness >= 32)
        *set block_upgradeable true
        *set can_spend_insight true
*if (dodge_level = 0)
    *if ((stat_mental >= 15) and (stat_toughness >= 15))
        *set dodge_upgradeable true
        *set can_spend_insight true
*elseif (dodge_level = 1)
    *if ((stat_mental >= 24) and (stat_toughness >= 24))
        *set dodge_upgradeable true
        *set can_spend_insight true
*if (counter_level = 0)
    *if (stat_mental >= 18)
        *set counter_upgradeable true
        *set can_spend_insight true
*elseif (counter_level = 1)
    *if (stat_mental >= 32)
        *set counter_upgradeable true
        *set can_spend_insight true
*return

*label choose_where_to_spend_insight
*choice
    *if ((jab_upgradeable) and (jab_level = 0)) #Sharpen your jab.
        Jab-jab. Jab-jab. Jab-jab. They thwack into the focus mitt, as usual.

        Coach Lam signals you to stop. He walks a slow circle around you. Says nothing.

        Back in front of you, he taps your lead shoulder with his mitt. You let it drop a fraction.

        Jab-jab. Your fist goes out straighter, smacks the mitt. Comes back faster.

        Jab. Smack. Retracts by itself.

        Again.

        You save the feeling.

        *gosub upgrade_jab
    *if ((jab_upgradeable) and (jab_level = 1)) #Refine your jab further.
        Coach Lam holds up a mitt. You jab it.

        "Move."

        You circle. He follows. You step out. He chases. You step in, jab.

        "Keep jabbing."

        You step back and jab. Circle left, jab. Duck, come out with a jab.

        Some of them miss. Some pull you off balance.

        Again. Your feet keep moving. You send out the jab without waiting for your feet to stop.

        *gosub upgrade_jab
    *if ((flurry_upgradeable) and (flurry_level = 0)) #Refine your flurry.
        You whale on the heavy bag. Not even trying to move it. Just making as much noise as you can.

        A dozen punches. Ten. Fifteen. You lose count. A different kind of tired.

        Head, body, side. Straight punches become hooks. Hooks become straights. Someone looks over at the drumbeat of smacks.

        Even more.

        You've forgotten the sequence already, but your arms haven't.

        *gosub upgrade_flurry
    *if ((flurry_upgradeable) and (flurry_level = 1)) #Tighten your flurry further.
        Coach Lam holds up his mitts. You start punching.

        Jab, cross, hook, cross. Faster. Another hook.

        A mitt smacks you on the forehead.

        "Hands up."

        Again. Jab, cross, jab, hook. Hands up. He steps back. You follow, still punching.

        Another smack on the forehead.

        "Easy."

        Again. Head, body, head. Hands up. Hook, cross, guard. The mitt comes and you take it on your gloves.

        You push him back across the mats without rushing.

        *gosub upgrade_flurry
    *if ((combo_upgradeable) and (combo_level = 0)) #Develop your combinations.
        "One-one-two!" Jab-jab-cross.

        "One-two-five-two!" Jab-cross-uppercut-cross.

        "One-six-three-two!" You don't use that one much.

        More. Different numbers.

        You stop thinking about separate punches. Each combo has its own rhythm now.

        "Nine-six-three-three. Zero-five-four-five."

        Hm.

        Oh, Coach Lam was on the phone. He turns his attention back to you.

        *gosub upgrade_combo
    *if ((combo_upgradeable) and (combo_level = 1)) #Integrate your combinations.
        "One-two-three."

        Jab, cross, hook.

        "Again."

        Jab, cross. Coach Lam drops the mitt. You throw the hook anyway, into the air.

        "Good. Now, watch." He holds both mitts up.

        Jab, cross. A mitt appears at his ribs. You dig in.

        Jab, cross. A mitt beside his head. Hook.

        Again.

        You have to think, have to match the mitt to the punch.

        "It'll come." Coach Lam wanders off.

        *gosub upgrade_combo
    *if ((block_upgradeable) and (block_level = 0)) #Stabilise your guard.
        Coach Lam jabs at your forehead. Your arms shoot up.

        He shakes his head. Nudges your gloves down.

        The same jab. Your arms go up again.

        Ten more times. By the end of it, your gloves just pop up a bit.

        He nods. The next time, a hook comes after the jab. Your guard swings across, chasing it.

        Coach Lam says, "We can work on that next time."

        *gosub upgrade_block
    *if ((block_upgradeable) and (block_level = 1)) #Adapt your guard.
        Coach Lam jabs at your forehead. You catch it with your gloves. Then a hook. You swing your guard across to meet it.

        A body shot slips in, too fast for you to block.

        "Don't dodge. Block."

        Block the jab. Block the hook. The body shot's still too fast.

        "I can't get it in time."

        "Because you're not ready."

        Block the jab. Block the hook. Your guard's shifting already. Block the body shot.

        "A good start."
        
        *gosub upgrade_block
    *if ((dodge_upgradeable) and (dodge_level = 0)) #Learn to slip and dodge.
        Coach Lam jabs at your forehead. You fling your body sideways.

        He shakes his head. "Less."

        The same jab. You jerk your whole body to the side.

        Again. You start to turn your shoulders instead, bend your knees a little. The glove passes closer each time.

        Too far. Too close.

        The glove passes close enough that you feel the air whoosh.

        *gosub upgrade_dodge

    *if ((dodge_upgradeable) and (dodge_level = 1)) #Evade and flow through attacks.
        Coach Lam jabs at your forehead. You slip outside.

        A cross follows right after. You slip that too. Another jab, another cross.

        Coach Lam stops and points at your feet. They've drifted almost level. You're square.

        You try again. Jab, slip, cross, slip. A hook. You roll.

        Your feet barely move. Your weight shifts from side to side, always returning to centre.

        When Coach Lam stops punching, you're exactly where you started.

        *gosub upgrade_dodge

    *if ((counter_upgradeable) and (counter_level = 0)) #Learn to counter.
        Coach Lam jabs at your forehead. You slip it and then throw the cross.

        He shakes his head. "Too slow."

        The same jab. You slip, throw the cross faster.

        "No."

        Again. Slip, cross. Slip, cross. Coach Lam keeps shaking his head.

        "Slow down. And be faster."

        Oh. You get it now. The jab comes again. You slip, and the cross comes with it.

        "Good."

        *gosub upgrade_counter

    *if ((counter_upgradeable) and (counter_level = 1)) #Anticipate openings to counter.
        Coach Lam has his gloves in front of his face. "Let's practise counters."

        You wait to slip his jab.

        You wait.

        You wait some more.

        You raise your eyebrows. Coach Lam says, "Go ahead."

        You step back, circle. Nothing happens.

        You edge into range and lean forward. The jab comes out and lands on your gloves.

        Interesting. You find that range again, lean forward once more. This time, you slip the jab and send out the cross.

        "Good."

        *gosub upgrade_counter

    #Don't develop your insight this month.
        *set stop_spending_insights true
        You keep your boxing insight, latent. Waiting until a new technique reveals itself.
*return

*label upgrade_jab
*set boxing_insights_unspent -1
*set boxing_insights_spent +1
*if (jab_level = 0)
    *set jab_level 1
    *set jab "[i]Sharp Jab[/i]"
*elseif (jab_level = 1)
    *set jab_level 2
    *set jab "[i]Tuned Jab[/i]"
*return

*label upgrade_flurry
*set boxing_insights_unspent -1
*set boxing_insights_spent +1
*if (flurry_level = 0)
    *set flurry_level 1
    *set flurry "[i]Fast Flurry[/i]"
*elseif (flurry_level = 1)
    *set flurry_level 2
    *set flurry "[i]Controlled Flurry[/i]"
*return

*label upgrade_combo
*set boxing_insights_unspent -1
*set boxing_insights_spent +1
*if (combo_level = 0)
    *set combo_level 1
    *set combo "[i]Standard Combo[/i]"
*elseif (combo_level = 1)
    *set combo_level 2
    *set combo "[i]Chain Combo[/i]"
*return

*label upgrade_block
*set boxing_insights_unspent -1
*set boxing_insights_spent +1
*if (block_level = 0)
    *set block_level 1
    *set block "[i]Solid Block[/i]"
*elseif (block_level = 1)
    *set block_level 2
    *set block "[i]Rolling Block[/i]"
*return

*label upgrade_dodge
*set boxing_insights_unspent -1
*set boxing_insights_spent +1
*if (dodge_level = 0)
    *set dodge_level 1
    *set dodge "[i]Fluid Dodge[/i]"
*elseif (dodge_level = 1)
    *set dodge_level 2
    *set dodge "[i]Quiet Dodge[/i]"
*return

*label upgrade_counter
*set boxing_insights_unspent -1
*set boxing_insights_spent +1
*if (counter_level = 0)
    *set counter_level 1
    *set counter "[i]Basic Counter[/i]"
*elseif (counter_level = 1)
    *set counter_level 2
    *set counter "[i]Predictive Counter[/i]"
*return