function generate_combatunit($combatunit_id = 0) { $CI =& get_instance(); $CI->load->model('commandmodel'); $CI->load->model('formationmodel'); $CI->load->model('combatunitmodel'); $CI->load->model('combatteammodel'); // Add three combat teams to this combat unit $combatunit = $CI->combatunitmodel->get_by_id($combatunit_id); for ($i = 0; $i < 3; $i++) { $combatteam = new stdClass(); $combatteam->name = 'Company ' . ($i + 1); $combatteam->combatunit_id = $combatunit_id; $CI->combatteammodel->create($combatteam); } // Generate each combat team $combatteams = $CI->combatteammodel->get_by_combatunit($combatunit_id); foreach ($combatteams as $c) { generate_combatteam($c->combatteam_id); } // Calculate this combatunit calculate_combatunit($combatunit_id); }
/** * Randomly generate a combat team from a RAT table * The RAT table is inherited from the parent formation */ function generate($combatteam_id = 0) { generate_combatteam($combatteam_id); $this->session->set_flashdata('notice', 'Combat team generated.'); redirect('combatteam/view/' . $combatteam_id, 'refresh'); }