<?php

global $session, $badguy, $battle;
require_once "modules/titans/lib/lib.php";
page_header("Titan!");
$titanid = httpget("titanid");
//battle - do this in a function in the lib file?
$titan = titans_load_battle($titanid);
titans_show_log($titan);
if ($battle) {
    include_once "battle.php";
    if (httpget('op') == "run") {
        titans_leave_battle($titan);
        redirect("runmodule.php?module=worldmapen&op=continue&fledtitan=true");
    }
    if ($victory || $titan['creature']['creaturehealth'] < 1) {
        //kill the titan
        $titan = titans_kill_titan($titan);
    } else {
        if ($defeat) {
            titans_save_battle($titan);
            titans_show_comrades($titan);
            titans_leave_battle_ko($titan);
            require_once "lib/forestoutcomes.php";
            forestdefeat(array($badguy), ", a Titan");
            //set the player's Location properly so they don't get bumped back to IC
            $session['user']['location'] = get_module_pref("lastCity", "worldmapen");
        } else {
            require_once "lib/fightnav.php";
            fightnav(true, true, "runmodule.php?module=titans&titanop=battle&titanid=" . $titanid, true);
        }
<?php

global $session, $badguy, $battle;
require_once "modules/titans/lib/lib.php";
page_header("Titans!");
//battle - do this in a function in the lib file?
$titan = titans_load_battle(1);
titans_show_log($titan);
if ($battle) {
    include_once "battle.php";
    if (httpget('op') == "run") {
        titans_leave_battle($titan);
        redirect("runmodule.php?module=worldmapen&op=continue&fledtitan=true");
    }
    if ($victory) {
        //award player with exp
        //send players Req to their bank based on the battlelog
    } else {
        if ($defeat) {
            titans_save_battle($titan);
            titans_show_comrades($titan);
            titans_leave_battle($titan);
            require_once "lib/forestoutcomes.php";
            forestdefeat($badguy, ", a Titan");
        } else {
            require_once "lib/fightnav.php";
            fightnav(true, true, "runmodule.php?module=titans&titanop=beta");
        }
    }
}
titans_save_battle($titan);