function choosePosition() { if (Chance_Percent(12)) { return 'T'; } elseif (Chance_Percent(24)) { return 'S'; } elseif (Chance_Percent(50)) { return 'M'; } else { return 'A'; } }
function starte_angriff($teamname_att, $teamname_def, $stark_att, $stark_def) { global $minute, $tore, $sql3, $spielbericht, $fouls, $gelbe_karten, $rote_karten, $abseits, $schuesse, $taktiken; // input values: attacker's name, defender's name, attacker's strength array, defender's strength array // players' strength values vary from 0.1 to 9.9 $spielbericht .= '<p>' . $minute . '\': ' . kommentar($teamname_att, 'attack'); if (Chance_Percent(50 * strengths_weight($stark_att['M']) / strengths_weight($stark_def['M']) * tactics_weight($taktiken[$teamname_att][0]) * tactics_weight($taktiken[$teamname_def][0]) * tactics_weight($taktiken[$teamname_att][1]) / tactics_weight($taktiken[$teamname_att][2]))) { // attacking team passes 1st third of opponent's field side $spielbericht .= ' ' . kommentar($teamname_def, 'advance'); if (Chance_Percent(25 * tactics_weight($taktiken[$teamname_def][5]))) { // the defending team fouls the attacking team $fouls[$teamname_def]++; $spielbericht .= ' ' . kommentar($teamname_def, 'foul'); if (Chance_Percent(30)) { // yellow card for the defending team $gelbe_karten[$teamname_def]++; weakenTeam($sql3['team1'], $teamname_def, 'yellow'); $spielbericht .= ' ' . kommentar($teamname_def, 'yellow'); } elseif (Chance_Percent(3)) { // red card for the defending team $rote_karten[$teamname_def]++; weakenTeam($sql3['team1'], $teamname_def, 'red'); $spielbericht .= ' ' . kommentar($teamname_def, 'red'); } // indirect free kick $spielbericht .= ' ' . kommentar($teamname_att, 'iFreeKick'); $schuesse[$teamname_att]++; if (Chance_Percent(30 * strengths_weight($stark_att['S']) / strengths_weight($stark_def['A']))) { // shot at the goal $spielbericht .= ' ' . kommentar($teamname_att, 'iFreeKick_shot'); if (Chance_Percent(30 * strengths_weight($stark_att['S']) / strengths_weight($stark_def['T']))) { // attacking team scores $tore[$teamname_att]++; $spielbericht .= ' ' . kommentar($teamname_att, 'shot_score'); } else { // defending goalkeeper saves $spielbericht .= ' ' . kommentar($teamname_def, 'iFreeKick_shot_save'); } } else { // defending team cleares the ball $spielbericht .= ' ' . kommentar($teamname_def, 'iFreeKick_clear'); } } elseif (Chance_Percent(17) * tactics_weight($taktiken[$teamname_att][0]) * tactics_weight($taktiken[$teamname_att][2])) { // attacking team is caught offside $abseits[$teamname_att]++; $spielbericht .= ' ' . kommentar($teamname_att, 'offside'); } else { // attack isn't interrupted // attack passes the 2nd third of the opponent's field side - good chance $spielbericht .= ' ' . kommentar($teamname_def, 'advance_further'); if (Chance_Percent(25 * tactics_weight($taktiken[$teamname_def][5]))) { // the defending team fouls the attacking team $fouls[$teamname_def]++; $spielbericht .= ' ' . kommentar($teamname_def, 'foul'); if (Chance_Percent(33)) { // yellow card for the defending team $gelbe_karten[$teamname_def]++; weakenTeam($sql3['team1'], $teamname_def, 'yellow'); $spielbericht .= ' ' . kommentar($teamname_def, 'yellow'); } elseif (Chance_Percent(3)) { // red card for the defending team $rote_karten[$teamname_def]++; weakenTeam($sql3['team1'], $teamname_def, 'red'); $spielbericht .= ' ' . kommentar($teamname_def, 'red'); } if (Chance_Percent(19 * strengths_weight($stark_att['S']) / strengths_weight($stark_def['A']))) { // penalty for the attacking team $schuesse[$teamname_att]++; $spielbericht .= ' ' . kommentar($teamname_att, 'penalty'); if (Chance_Percent(77) / strengths_weight($stark_def['T'])) { // attacking team scores $tore[$teamname_att]++; $spielbericht .= ' ' . kommentar($teamname_att, 'shot_score'); } elseif (Chance_Percent(50)) { // shot misses the goal $spielbericht .= ' ' . kommentar($teamname_att, 'penalty_miss'); } else { // defending goalkeeper saves $spielbericht .= ' ' . kommentar($teamname_def, 'penalty_save'); } } else { // direct free kick $spielbericht .= ' ' . kommentar($teamname_att, 'dFreeKick'); $schuesse[$teamname_att]++; if (Chance_Percent(40 * strengths_weight($stark_att['S']))) { // shot at the goal $spielbericht .= ' ' . kommentar($teamname_att, 'dFreeKick_shot'); if (Chance_Percent(40 / strengths_weight($stark_def['T']))) { // attacking team scores $tore[$teamname_att]++; $spielbericht .= ' ' . kommentar($teamname_att, 'shot_score'); } else { // defending goalkeeper saves $spielbericht .= ' ' . kommentar($teamname_def, 'dFreeKick_shot_save'); } } else { // defending team cleares the ball $spielbericht .= ' ' . kommentar($teamname_def, 'dFreeKick_clear'); } } } elseif (Chance_Percent(62 * strengths_weight($stark_att['S']) / strengths_weight($stark_def['A']) * tactics_weight($taktiken[$teamname_att][2]) * tactics_weight($taktiken[$teamname_att][3]))) { // shot at the goal $schuesse[$teamname_att]++; $spielbericht .= ' ' . kommentar($teamname_att, 'shot'); if (Chance_Percent(30 * strengths_weight($stark_att['S']) / strengths_weight($stark_def['T']))) { // the attacking team scores $tore[$teamname_att]++; $spielbericht .= ' ' . kommentar($teamname_att, 'shot_score'); } else { if (Chance_Percent(50 * strengths_weight($stark_def['A']))) { // the defending defenders block the shot $spielbericht .= ' ' . kommentar($teamname_att, 'shot_block'); } else { // the defending goalkeeper saves $spielbericht .= ' ' . kommentar($teamname_def, 'shot_save'); } } } else { // attack is stopped $spielbericht .= ' ' . kommentar($teamname_def, 'stopped'); if (Chance_Percent(15 * strengths_weight($stark_def['A']) / strengths_weight($stark_att['M']) * tactics_weight($taktiken[$teamname_att][1]) * tactics_weight($taktiken[$teamname_att][3]) * tactics_weight($taktiken[$teamname_def][4]))) { // quick counter attack - playing on the break $stark_att['A'] = $stark_att['A'] * 0.8; // weaken the current attacking team's defense $spielbericht .= ' ' . kommentar($teamname_def, 'quickCounterAttack'); $spielbericht .= ' [' . $tore[$sql3['team1']] . ':' . $tore[$sql3['team2']] . ']</p>'; // close comment line return starte_angriff($teamname_def, $teamname_att, $stark_def, $stark_att); // new attack - this one is finished } } } } elseif (Chance_Percent(15 * strengths_weight($stark_def['A']) / strengths_weight($stark_att['S']) * tactics_weight($taktiken[$teamname_att][3]) * tactics_weight($taktiken[$teamname_def][4]))) { // attack is stopped // quick counter attack - playing on the break $spielbericht .= ' ' . kommentar($teamname_def, 'stopped'); $stark_att['A'] = $stark_att['A'] * 0.8; // weaken the current attacking team's defense $spielbericht .= ' ' . kommentar($teamname_def, 'quickCounterAttack'); $spielbericht .= ' [' . $tore[$sql3['team1']] . ':' . $tore[$sql3['team2']] . ']</p>'; // close comment line return starte_angriff($teamname_def, $teamname_att, $stark_def, $stark_att); // new attack - this one is finished } else { // ball goes into touch - out of the field $spielbericht .= ' ' . kommentar($teamname_def, 'throwIn'); if (Chance_Percent(33)) { // if a new chance is created if (Chance_Percent(50 * strengths_weight($stark_att['M']) / strengths_weight($stark_def['M']))) { // throw-in for the attacking team $spielbericht .= ' ' . kommentar($teamname_def, 'throwIn_att'); $spielbericht .= ' [' . $tore[$sql3['team1']] . ':' . $tore[$sql3['team2']] . ']</p>'; // close comment line return starte_angriff($teamname_att, $teamname_def, $stark_att, $stark_def); // new attack - this one is finished } else { // throw-in for the defending team $spielbericht .= ' ' . kommentar($teamname_def, 'throwIn_def'); $spielbericht .= ' [' . $tore[$sql3['team1']] . ':' . $tore[$sql3['team2']] . ']</p>'; // close comment line return starte_angriff($teamname_def, $teamname_att, $stark_def, $stark_att); // new attack - this one is finished } } } $spielbericht .= ' [' . $tore[$sql3['team1']] . ':' . $tore[$sql3['team2']] . ']</p>'; // close comment line return TRUE; // finish the attack }