Guest User

Untitled

a guest
Sep 2nd, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. // -- Creating an AI --
  2. // create(integer id, String behavior)
  3. //
  4. // -- Using an AI --
  5. // run(unit aiUnit, Battle whichBattle)
  6.  
  7. struct AI
  8.  
  9. private string behavior
  10. private integer id
  11. private unit aiUnit
  12. private Battle battle
  13. private string inspect
  14.  
  15. public method getBattle takes nothing returns Battle
  16. return .battle
  17. endmethod
  18.  
  19. public method setBattle takes Battle battle returns nothing
  20. set .battle = battle
  21. endmethod
  22.  
  23. public method getId takes nothing returns integer
  24. return .id
  25. endmethod
  26.  
  27. public method setId takes integer id returns nothing
  28. set .id = id
  29. endmethod
  30.  
  31. public method getBehavior takes nothing returns string
  32. return .behavior
  33. endmethod
  34.  
  35. public method setBehavior takes string behavior returns nothing
  36. set .behavior = behavior
  37. endmethod
  38.  
  39. public method getAIUnit takes nothing returns unit
  40. return .aiUnit
  41. endmethod
  42.  
  43. public method setInspect takes string s returns nothing
  44. set .inspect = s
  45. endmethod
  46.  
  47. public method getInspect takes nothing returns string
  48. return .inspect
  49. endmethod
  50.  
  51. /**
  52. * Executes the specified AI function
  53. */
  54. public method run takes unit aiUnit, Battle whichBattle returns nothing
  55. set .battle = whichBattle
  56. set AIList_whichAI = this
  57. set .aiUnit = aiUnit
  58. call ExecuteFunc(this.behavior)
  59. set .battle = 0
  60. set .aiUnit = null
  61.  
  62. endmethod
  63.  
  64. static method create takes integer id, string behavior, string inspect returns thistype
  65. local thistype new = thistype.allocate()
  66. call new.setBehavior(behavior)
  67. call new.setId(id)
  68. call new.setInspect(inspect)
  69. return new
  70. endmethod
  71.  
  72. endstruct
Add Comment
Please, Sign In to add comment