Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function queen_attack_menu(){
- $items['queen_attack']=array(
- 'title' => "Queen Attack!",
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('queen_attack_form'),
- 'access callback' => TRUE,
- 'type' => MENU_NORMAL_ITEM,
- );
- $items['attack_calculated']=array(
- 'title' => "Attack Results!",
- 'page callback' => 'attack_results',
- 'access callback' => TRUE,
- 'type' => MENU_CALLBACK,
- );
- return $items;
- //chess board 8x8 so coordinates 1-8 for each side
- function queen_attack_form(){
- $form["queen_coordinates_x"] = array(
- '#title' => 'Queen Horizontal Coordinate',
- '#type' => 'select',
- "#options" => array(
- 1,
- 2,
- 3,
- 4,
- 5,
- 6,
- 7,
- 8
- ),
- '#description' => t('Enter your starting horizontal coordinate for your Queen'),
- );
- $form['queen_coordinates_y'] = array(
- '#title' => 'Queen Vertical Coordinate',
- '#type' => 'select',
- '#options' => array(
- 1,
- 2,
- 3,
- 4,
- 5,
- 6,
- 7,
- 8
- ),
- '#description' => t('Enter your starting vertical coordinate for your Queen'),
- );
- $form['target__coordinates_x'] = array(
- '#title' => 'Target Horizontal Coordinate',
- '#type' => "select",
- '#options' => array(
- 1,
- 2,
- 3,
- 4,
- 5,
- 6,
- 7,
- 8
- ),
- '#description' => t('Enter the horizontal coordinate for the target piece'),
- );
- $form['target_coordinates_y']= array(
- '#title' => 'Target Vertical Coordinate',
- '#type' => "select",
- '#options' => array(
- 1,
- 2,
- 3,
- 4,
- 5,
- 6,
- 7,
- 8
- ),
- '#description' => t('Enter the vertical coordinate for the target piece'),
- );
- $form['submit'] = array(
- '#type' => 'submit',
- '#value' => "Queen, Attack!",
- );
- return $form;
- function queen_attack_form_submit($form, $form_state){
- //$queen_x;
- //$queen_y;
- //$target_x;
- //$target_y;
- $queen_coords = $form_state['values'] ['queen_coordinates_x'];//['queen_coordinates_y'];
- $target_coords = $form_state['values'] ['target__coordinates_x'];//['target_coordinates_y'];
- //session hit or miss
- $_SESSION['queen_coords'] = $queen_coords;
- $_SESSION['target_coords'] = $target_coords;
- $form_state['redirect'] = 'attack_calculated';
- function attack_results(){
- $result = 'Hit or Missed';
- return '<p> Queen Coords: ' . $_SESSION['queen_coords'] . '</p> <p> Target Coords: ' . $_SESSION['target_coords'] . '</p>';
- // return '<h3> Your Queen' . $result . 'the target! </h3>';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement