/[drupal]/contributions/modules/game/game.module
ViewVC logotype

Diff of /contributions/modules/game/game.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.52.2.19, Mon Dec 1 00:15:02 2008 UTC revision 1.52.2.20, Mon Dec 1 00:41:11 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: game.module,v 1.52.2.18 2008/11/29 03:30:39 morbus Exp $  // $Id: game.module,v 1.52.2.19 2008/12/01 00:15:02 morbus Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 12  Line 12 
12   * [19:16] <litwol|mac> mydiv.scrollTop = mydiv.scrollHeight   * [19:16] <litwol|mac> mydiv.scrollTop = mydiv.scrollHeight
13   * @todo create a Log tab for the user under logs.   * @todo create a Log tab for the user under logs.
14   * @todo admin settings for name of game. use on tab/menu items.   * @todo admin settings for name of game. use on tab/menu items.
  * @todo add missing/null/unowned bid checking to game_battle_process_form();  
15   * @todo run an EXPLAIN on game_log_recent (8 seconds? wtf.)   * @todo run an EXPLAIN on game_log_recent (8 seconds? wtf.)
16   * @todo error if there are no mobs available (modules, etc.).   * @todo error if there are no mobs available (modules, etc.).
  * @todo game_battle_play() needs to complain about missing params.  
17   * @todo go through and fine-tooth game_battle_play().   * @todo go through and fine-tooth game_battle_play().
18   * @todo move the dynamic 'hp' values into $state?   * @todo move the dynamic 'hp' values into $state?
19   * @todo add in uname to the variables (and other missing values).   * @todo add in uname to the variables (and other missing values).
# Line 46  function game_menu() { Line 44  function game_menu() {
44    $items['game/battle/%game_battle'] = array(    $items['game/battle/%game_battle'] = array(
45      'access arguments'  => array('play game'),      'access arguments'  => array('play game'),
46      'page callback'     => 'drupal_get_form',      'page callback'     => 'drupal_get_form',
47      'page arguments'    => array('game_battle_process_form', 2),      'page arguments'    => array('game_battle_turn_form', 2),
48      'title'             => 'Game battle',      'title'             => 'Game battle',
49      'type'              => MENU_CALLBACK,      'type'              => MENU_CALLBACK,
50    );    );
# Line 127  function game_battle_init_form_submit($f Line 125  function game_battle_init_form_submit($f
125   * @param $battle   * @param $battle
126   *   A loaded battle from game_battle_load() (menu wildcard loader).   *   A loaded battle from game_battle_load() (menu wildcard loader).
127   */   */
128  function game_battle_process_form(&$form_state, $battle) {  function game_battle_turn_form(&$form_state, $battle) {
129    global $user; // keep structure.    global $user; // keep structure.
130    $form['game']['#tree'] = TRUE;    $form['game']['#tree'] = TRUE;
131    $state = game_state_load($user->uid, $battle['bid']);    $state = game_state_load($user->uid, $battle['bid']);
# Line 169  function game_battle_process_form(&$form Line 167  function game_battle_process_form(&$form
167  /**  /**
168   * Form #submit callback; starts a battle and passes to main handler.   * Form #submit callback; starts a battle and passes to main handler.
169   */   */
170  function game_battle_process_form_submit($form, &$form_state) {  function game_battle_turn_form_submit($form, &$form_state) {
171    global $user; // side effects may include uncontrollable muscle movement.    global $user; // side effects may include uncontrollable muscle movement.
172    $state = game_state_load($user->uid, $form_state['values']['game']['bid']);    $state = game_state_load($user->uid, $form_state['values']['game']['bid']);
173    
# Line 220  function game_battle_play($state) { Line 218  function game_battle_play($state) {
218        // loop through all the attackers remaining creatures and attack.        // loop through all the attackers remaining creatures and attack.
219        foreach (array_keys($state['battle']['parties'][$attacker_uid]) as $attacking_mob_num) {        foreach (array_keys($state['battle']['parties'][$attacker_uid]) as $attacking_mob_num) {
220          $state['battle']['state']['attacker']['mob_num'] = $attacking_mob_num;          $state['battle']['state']['attacker']['mob_num'] = $attacking_mob_num;
221            // @todo the above line may be removable once we split this up more.
222    
223          // if this mob has a target opponent and mob, use it. otherwise, random remaining.          // let other modules interject on this attack.
224          // this should really only be used when the AI is not automatically picking an          drupal_alter('game_battle_attack_start', $state);
         // opponent; users would always choose opponent + mob via the standard form UI.  
         // @todo this defaulting should eventually go into an AI-sorta module.  
         if (!$state['battle']['state']['attacker']['party'][$attacking_mob_num]['target_uid']) {  
           $state['battle']['state']['attacker']['party'][$attacking_mob_num]['target_uid'] = array_rand(array_diff_key($state['battle']['parties'], array($attacker_uid => 1)));  
           $state['battle']['state']['attacker']['party'][$attacking_mob_num]['target_mob_num'] = array_rand($state['battle']['parties'][$state['battle']['state']['attacker']['party'][$attacking_mob_num]['target_uid']]);  
           $state['battle']['state']['attacker']['party'][$attacking_mob_num]['attack'] = array_rand($state['battle']['parties'][$attacker_uid][$attacking_mob_num]['actions']);  
         }  
225    
226          // roll attack for success or failure.          // roll attack and call teh hookz.
227          $state = game_battle_attack($state);          $state = game_battle_attack($state);
228    
229          // @todo move this and other damage related stuff into a new function.          // @todo move this and other damage related stuff into a new function.

Legend:
Removed from v.1.52.2.19  
changed lines
  Added in v.1.52.2.20

  ViewVC Help
Powered by ViewVC 1.1.2