Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.52 KB | None | 0 0
  1. <?php
  2.  
  3. function queen_attack_menu(){
  4. $items['queen_attack']=array(
  5. 'title' => "Queen Attack!",
  6. 'page callback' => 'drupal_get_form',
  7. 'page arguments' => array('queen_attack_form'),
  8. 'access callback' => TRUE,
  9. 'type' => MENU_NORMAL_ITEM,
  10. );
  11. $items['attack_calculated']=array(
  12. 'title' => "Attack Results!",
  13. 'page callback' => 'attack_results',
  14. 'access callback' => TRUE,
  15. 'type' => MENU_CALLBACK,
  16. );
  17. return $items;
  18.  
  19. //chess board 8x8 so coordinates 1-8 for each side
  20. function queen_attack_form(){
  21. $form["queen_coordinates_x"] = array(
  22. '#title' => 'Queen Horizontal Coordinate',
  23. '#type' => 'select',
  24. "#options" => array(
  25. 1,
  26. 2,
  27. 3,
  28. 4,
  29. 5,
  30. 6,
  31. 7,
  32. 8
  33. ),
  34. '#description' => t('Enter your starting horizontal coordinate for your Queen'),
  35. );
  36. $form['queen_coordinates_y'] = array(
  37. '#title' => 'Queen Vertical Coordinate',
  38. '#type' => 'select',
  39. '#options' => array(
  40. 1,
  41. 2,
  42. 3,
  43. 4,
  44. 5,
  45. 6,
  46. 7,
  47. 8
  48. ),
  49. '#description' => t('Enter your starting vertical coordinate for your Queen'),
  50. );
  51. $form['target__coordinates_x'] = array(
  52. '#title' => 'Target Horizontal Coordinate',
  53. '#type' => "select",
  54. '#options' => array(
  55. 1,
  56. 2,
  57. 3,
  58. 4,
  59. 5,
  60. 6,
  61. 7,
  62. 8
  63. ),
  64. '#description' => t('Enter the horizontal coordinate for the target piece'),
  65. );
  66. $form['target_coordinates_y']= array(
  67. '#title' => 'Target Vertical Coordinate',
  68. '#type' => "select",
  69. '#options' => array(
  70. 1,
  71. 2,
  72. 3,
  73. 4,
  74. 5,
  75. 6,
  76. 7,
  77. 8
  78. ),
  79. '#description' => t('Enter the vertical coordinate for the target piece'),
  80. );
  81.  
  82. $form['submit'] = array(
  83. '#type' => 'submit',
  84. '#value' => "Queen, Attack!",
  85. );
  86.  
  87. return $form;
  88.  
  89. function queen_attack_form_submit($form, $form_state){
  90. //$queen_x;
  91. //$queen_y;
  92. //$target_x;
  93. //$target_y;
  94. $queen_coords = $form_state['values'] ['queen_coordinates_x'];//['queen_coordinates_y'];
  95. $target_coords = $form_state['values'] ['target__coordinates_x'];//['target_coordinates_y'];
  96.  
  97. //session hit or miss
  98.  
  99. $_SESSION['queen_coords'] = $queen_coords;
  100. $_SESSION['target_coords'] = $target_coords;
  101. $form_state['redirect'] = 'attack_calculated';
  102.  
  103. function attack_results(){
  104. $result = 'Hit or Missed';
  105. return '<p> Queen Coords: ' . $_SESSION['queen_coords'] . '</p> <p> Target Coords: ' . $_SESSION['target_coords'] . '</p>';
  106.  
  107. // return '<h3> Your Queen' . $result . 'the target! </h3>';
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement