Skip to content
Browse files

cleanup

  • Loading branch information...
1 parent 9ef74ee commit 2fab0ebed6e3b672352ba28576e50b29632a04b0 @burtbeckwith burtbeckwith committed
Showing with 1,149 additions and 1,196 deletions.
  1. +5 −32 GoblinGrailsPlugin.groovy
  2. +1 −1 INSTALL.md
  3. +6 −6 README.md
  4. +26 −26 grails-app/conf/BootStrap.groovy
  5. +26 −37 grails-app/conf/BuildConfig.groovy
  6. +1 −1 grails-app/conf/de/dewarim/goblin/filters/UserFilters.groovy
  7. +2 −3 grails-app/conf/spring/resources.groovy
  8. +30 −20 grails-app/controllers/de/dewarim/goblin/AcademyController.groovy
  9. +2 −2 grails-app/controllers/de/dewarim/goblin/BaseController.groovy
  10. +1 −1 grails-app/controllers/de/dewarim/goblin/CaptchaController.groovy
  11. +24 −24 grails-app/controllers/de/dewarim/goblin/FightController.groovy
  12. +23 −26 grails-app/controllers/de/dewarim/goblin/GuildController.groovy
  13. +12 −14 grails-app/controllers/de/dewarim/goblin/HelpController.groovy
  14. +44 −40 grails-app/controllers/de/dewarim/goblin/ItemController.groovy
  15. +28 −28 grails-app/controllers/de/dewarim/goblin/MeleeController.groovy
  16. +24 −23 grails-app/controllers/de/dewarim/goblin/PlayerCharacterController.groovy
  17. +3 −5 grails-app/controllers/de/dewarim/goblin/PostOfficeController.groovy
  18. +32 −27 grails-app/controllers/de/dewarim/goblin/ProductionController.groovy
  19. +45 −33 grails-app/controllers/de/dewarim/goblin/QuestController.groovy
  20. +9 −9 grails-app/controllers/de/dewarim/goblin/RoleController.groovy
  21. +16 −25 grails-app/controllers/de/dewarim/goblin/ShopController.groovy
  22. +9 −8 grails-app/controllers/de/dewarim/goblin/TownController.groovy
  23. +11 −12 grails-app/controllers/de/dewarim/goblin/UserController.groovy
  24. +4 −2 grails-app/controllers/de/dewarim/goblin/admin/AcademyAdminController.groovy
  25. +0 −1 grails-app/controllers/de/dewarim/goblin/admin/AdminController.groovy
  26. +4 −2 grails-app/controllers/de/dewarim/goblin/admin/ArtistAdminController.groovy
  27. +4 −2 grails-app/controllers/de/dewarim/goblin/admin/CategoryAdminController.groovy
  28. +4 −4 grails-app/controllers/de/dewarim/goblin/admin/CombatAttributeAdminController.groovy
  29. +6 −5 grails-app/controllers/de/dewarim/goblin/admin/ComponentAdminController.groovy
  30. +4 −2 grails-app/controllers/de/dewarim/goblin/admin/ConfigAdminController.groovy
  31. +4 −2 grails-app/controllers/de/dewarim/goblin/admin/DiceAdminController.groovy
  32. +4 −2 grails-app/controllers/de/dewarim/goblin/admin/EncounterAdminController.groovy
  33. +4 −4 grails-app/controllers/de/dewarim/goblin/admin/EquipmentSlotTypeAdminController.groovy
  34. +4 −2 grails-app/controllers/de/dewarim/goblin/admin/FactionAdminController.groovy
  35. +4 −2 grails-app/controllers/de/dewarim/goblin/admin/FeatureAdminController.groovy
  36. +4 −2 grails-app/controllers/de/dewarim/goblin/admin/GuildAdminController.groovy
  37. +6 −4 grails-app/controllers/de/dewarim/goblin/admin/ImageAdminController.groovy
  38. +6 −4 grails-app/controllers/de/dewarim/goblin/admin/ItemAdminController.groovy
  39. +4 −2 grails-app/controllers/de/dewarim/goblin/admin/ItemFeatureAdminController.groovy
  40. +4 −2 grails-app/controllers/de/dewarim/goblin/admin/LicenseAdminController.groovy
  41. +4 −2 grails-app/controllers/de/dewarim/goblin/admin/MobAdminController.groovy
  42. +4 −2 grails-app/controllers/de/dewarim/goblin/admin/ProductAdminController.groovy
  43. +4 −2 grails-app/controllers/de/dewarim/goblin/admin/ProductCategoryAdminController.groovy
  44. +4 −2 grails-app/controllers/de/dewarim/goblin/admin/QuestAdminController.groovy
  45. +4 −2 grails-app/controllers/de/dewarim/goblin/admin/QuestGiverAdminController.groovy
  46. +4 −2 grails-app/controllers/de/dewarim/goblin/admin/QuestStepAdminController.groovy
  47. +4 −4 grails-app/controllers/de/dewarim/goblin/admin/RepMessageAdminController.groovy
  48. +4 −2 grails-app/controllers/de/dewarim/goblin/admin/RmmAdminController.groovy
  49. +4 −2 grails-app/controllers/de/dewarim/goblin/admin/ShopAdminController.groovy
  50. +6 −4 grails-app/controllers/de/dewarim/goblin/admin/ShopOwnerAdminController.groovy
  51. +3 −2 grails-app/controllers/de/dewarim/goblin/admin/SkillRequirementAdminController.groovy
  52. +4 −2 grails-app/controllers/de/dewarim/goblin/admin/TownAdminController.groovy
  53. +29 −45 grails-app/controllers/de/dewarim/goblin/cron/CronController.groovy
  54. +13 −9 grails-app/controllers/de/dewarim/goblin/landing/PortalController.groovy
  55. +2 −4 grails-app/controllers/de/dewarim/goblin/landing/ScoreController.groovy
  56. +2 −7 grails-app/controllers/de/dewarim/goblin/social/AddressBookController.groovy
  57. +11 −9 grails-app/controllers/de/dewarim/goblin/social/ChatterBoxController.groovy
  58. +61 −49 grails-app/controllers/de/dewarim/goblin/social/GoblinOrderController.groovy
  59. +30 −23 grails-app/controllers/de/dewarim/goblin/social/MailBoxController.groovy
  60. +4 −4 grails-app/domain/de/dewarim/goblin/Artist.groovy
  61. +8 −8 grails-app/domain/de/dewarim/goblin/Category.groovy
  62. +15 −18 grails-app/domain/de/dewarim/goblin/Creature.groovy
  63. +2 −2 grails-app/domain/de/dewarim/goblin/CreatureAttribute.groovy
  64. +7 −7 grails-app/domain/de/dewarim/goblin/Dice.groovy
  65. +7 −7 grails-app/domain/de/dewarim/goblin/EquipmentSlot.groovy
  66. +4 −6 grails-app/domain/de/dewarim/goblin/EquipmentSlotType.groovy
  67. +7 −7 grails-app/domain/de/dewarim/goblin/Feature.groovy
  68. +4 −4 grails-app/domain/de/dewarim/goblin/GlobalConfigEntry.groovy
  69. +2 −2 grails-app/domain/de/dewarim/goblin/GoblinScript.groovy
  70. +2 −2 grails-app/domain/de/dewarim/goblin/Help.groovy
  71. +4 −4 grails-app/domain/de/dewarim/goblin/HighScore.groovy
  72. +4 −4 grails-app/domain/de/dewarim/goblin/Image.groovy
  73. +2 −2 grails-app/domain/de/dewarim/goblin/License.groovy
  74. +3 −3 grails-app/domain/de/dewarim/goblin/RequiredSlot.groovy
  75. +2 −2 grails-app/domain/de/dewarim/goblin/Role.groovy
  76. +3 −4 grails-app/domain/de/dewarim/goblin/UserAccount.groovy
  77. +3 −3 grails-app/domain/de/dewarim/goblin/UserProperty.groovy
  78. +1 −1 grails-app/domain/de/dewarim/goblin/UserRole.groovy
  79. +8 −11 grails-app/domain/de/dewarim/goblin/combat/Combat.groovy
  80. +2 −2 grails-app/domain/de/dewarim/goblin/combat/CombatAttributeType.groovy
  81. +2 −2 grails-app/domain/de/dewarim/goblin/combat/CombatMessage.groovy
  82. +2 −2 grails-app/domain/de/dewarim/goblin/combat/CombatMessageArg.groovy
  83. +3 −3 grails-app/domain/de/dewarim/goblin/combat/Melee.groovy
  84. +5 −5 grails-app/domain/de/dewarim/goblin/combat/MeleeAction.groovy
  85. +3 −3 grails-app/domain/de/dewarim/goblin/combat/MeleeFighter.groovy
  86. +3 −3 grails-app/domain/de/dewarim/goblin/combat/WeaponAttribute.groovy
  87. +3 −5 grails-app/domain/de/dewarim/goblin/guild/Guild.groovy
  88. +4 −4 grails-app/domain/de/dewarim/goblin/guild/GuildMember.groovy
  89. +4 −4 grails-app/domain/de/dewarim/goblin/item/Item.groovy
  90. +3 −3 grails-app/domain/de/dewarim/goblin/item/ItemAttribute.groovy
  91. +5 −5 grails-app/domain/de/dewarim/goblin/item/ItemAttributeCondition.groovy
  92. +2 −2 grails-app/domain/de/dewarim/goblin/item/ItemCategory.groovy
  93. +3 −3 grails-app/domain/de/dewarim/goblin/item/ItemType.groovy
  94. +2 −2 grails-app/domain/de/dewarim/goblin/item/ItemTypeFeature.groovy
  95. +4 −4 grails-app/domain/de/dewarim/goblin/mob/EncounterMob.groovy
  96. +3 −6 grails-app/domain/de/dewarim/goblin/mob/Mob.groovy
  97. +5 −5 grails-app/domain/de/dewarim/goblin/mob/MobImage.groovy
  98. +4 −4 grails-app/domain/de/dewarim/goblin/mob/MobTemplate.groovy
  99. +2 −3 grails-app/domain/de/dewarim/goblin/pc/GoblinOrder.groovy
  100. +2 −2 grails-app/domain/de/dewarim/goblin/pc/OrderApplication.groovy
  101. +32 −33 grails-app/domain/de/dewarim/goblin/pc/PlayerCharacter.groovy
  102. +2 −2 grails-app/domain/de/dewarim/goblin/pc/PlayerMessage.groovy
  103. +3 −3 grails-app/domain/de/dewarim/goblin/pc/crafting/Component.groovy
  104. +2 −2 grails-app/domain/de/dewarim/goblin/pc/crafting/PlayerProduct.groovy
  105. +6 −6 grails-app/domain/de/dewarim/goblin/pc/crafting/Product.groovy
  106. +2 −2 grails-app/domain/de/dewarim/goblin/pc/crafting/ProductCategory.groovy
  107. +4 −5 grails-app/domain/de/dewarim/goblin/pc/crafting/ProductionJob.groovy
  108. +2 −2 grails-app/domain/de/dewarim/goblin/pc/crafting/ProductionResource.groovy
  109. +2 −2 grails-app/domain/de/dewarim/goblin/pc/crafting/SkillRequirement.groovy
  110. +3 −3 grails-app/domain/de/dewarim/goblin/pc/skill/CombatSkill.groovy
  111. +2 −2 grails-app/domain/de/dewarim/goblin/pc/skill/CreatureSkill.groovy
  112. +1 −1 grails-app/domain/de/dewarim/goblin/pc/skill/GeneralSkill.groovy
  113. +3 −3 grails-app/domain/de/dewarim/goblin/pc/skill/LearningQueueElement.groovy
  114. +2 −3 grails-app/domain/de/dewarim/goblin/pc/skill/ProductionSkill.groovy
  115. +3 −3 grails-app/domain/de/dewarim/goblin/pc/skill/Skill.groovy
  116. +3 −7 grails-app/domain/de/dewarim/goblin/pc/skill/SkillSet.groovy
  117. +5 −5 grails-app/domain/de/dewarim/goblin/quest/Encounter.groovy
  118. +4 −4 grails-app/domain/de/dewarim/goblin/quest/Quest.groovy
  119. +2 −2 grails-app/domain/de/dewarim/goblin/quest/QuestGiver.groovy
  120. +1 −1 grails-app/domain/de/dewarim/goblin/quest/QuestRequirement.groovy
  121. +16 −17 grails-app/domain/de/dewarim/goblin/quest/QuestStep.groovy
  122. +5 −6 grails-app/domain/de/dewarim/goblin/quest/QuestTemplate.groovy
  123. +4 −4 grails-app/domain/de/dewarim/goblin/quest/StepChild.groovy
  124. +4 −4 grails-app/domain/de/dewarim/goblin/reputation/Faction.groovy
  125. +2 −2 grails-app/domain/de/dewarim/goblin/reputation/Reputation.groovy
  126. +2 −2 grails-app/domain/de/dewarim/goblin/reputation/ReputationMessage.groovy
  127. +3 −3 grails-app/domain/de/dewarim/goblin/reputation/ReputationMessageMap.groovy
  128. +6 −6 grails-app/domain/de/dewarim/goblin/shop/Shop.groovy
  129. +2 −2 grails-app/domain/de/dewarim/goblin/shop/ShopCategory.groovy
  130. +8 −10 grails-app/domain/de/dewarim/goblin/shop/ShopOwner.groovy
  131. +2 −2 grails-app/domain/de/dewarim/goblin/social/AddressBook.groovy
  132. +2 −3 grails-app/domain/de/dewarim/goblin/social/ChatMessage.groovy
  133. +2 −3 grails-app/domain/de/dewarim/goblin/social/ChatterBox.groovy
  134. +2 −4 grails-app/domain/de/dewarim/goblin/social/Mail.groovy
  135. +2 −2 grails-app/domain/de/dewarim/goblin/social/MailBox.groovy
  136. +2 −2 grails-app/domain/de/dewarim/goblin/social/MailBoxType.groovy
  137. +10 −10 grails-app/domain/de/dewarim/goblin/ticks/Tick.groovy
  138. +3 −6 grails-app/domain/de/dewarim/goblin/town/Academy.groovy
  139. +2 −2 grails-app/domain/de/dewarim/goblin/town/AcademyLevel.groovy
  140. +9 −9 grails-app/domain/de/dewarim/goblin/town/AcademySkillSet.groovy
  141. +3 −3 grails-app/domain/de/dewarim/goblin/town/GuildAcademy.groovy
  142. +5 −5 grails-app/domain/de/dewarim/goblin/town/Town.groovy
  143. +3 −3 grails-app/routes/de/dewarim/goblin/routes/GoblinRouteBuilder.groovy
  144. +7 −9 grails-app/services/de/dewarim/goblin/AcademyService.groovy
  145. +2 −2 grails-app/services/de/dewarim/goblin/CategoryService.groovy
  146. +5 −9 grails-app/services/de/dewarim/goblin/ConfigService.groovy
  147. +5 −6 grails-app/services/de/dewarim/goblin/EmailerService.groovy
  148. +8 −11 grails-app/services/de/dewarim/goblin/FeatureService.groovy
  149. +2 −4 grails-app/services/de/dewarim/goblin/FightService.groovy
  150. +2 −4 grails-app/services/de/dewarim/goblin/GlobalConfigService.groovy
  151. +1 −1 grails-app/services/de/dewarim/goblin/GuildMemberService.groovy
  152. +1 −1 grails-app/services/de/dewarim/goblin/InputValidationService.groovy
  153. +7 −7 grails-app/services/de/dewarim/goblin/MeleeService.groovy
  154. +17 −17 grails-app/services/de/dewarim/goblin/MyMailService.groovy
  155. +0 −2 grails-app/services/de/dewarim/goblin/PlayerMessageService.groovy
  156. +14 −23 grails-app/services/de/dewarim/goblin/ProductionService.groovy
  157. +5 −5 grails-app/services/de/dewarim/goblin/QuestService.groovy
  158. +1 −1 grails-app/services/de/dewarim/goblin/RmmService.groovy
  159. +9 −12 grails-app/services/de/dewarim/goblin/SkillService.groovy
  160. +7 −8 grails-app/services/de/dewarim/goblin/TreasureService.groovy
  161. +7 −7 grails-app/services/de/dewarim/goblin/item/ItemService.groovy
  162. +1 −1 grails-app/services/de/dewarim/goblin/ticks/TickService.groovy
  163. +1 −1 src/groovy/de/dewarim/goblin/camel/LearningDelayer.groovy
  164. +1 −1 src/groovy/de/dewarim/goblin/exception/MonsterDeadException.groovy
  165. +1 −1 src/groovy/de/dewarim/goblin/exception/PlayerDeadException.groovy
  166. +1 −1 src/groovy/de/dewarim/goblin/exception/SimultaneousDeathException.groovy
  167. +7 −8 src/groovy/de/dewarim/goblin/item/script/HealSelf_1W6.groovy
  168. +4 −4 src/groovy/de/dewarim/goblin/quest/script/DeliverItem.groovy
  169. +5 −7 src/groovy/de/dewarim/goblin/quest/script/GetReward.groovy
  170. +5 −7 src/groovy/de/dewarim/goblin/quest/script/PickupItem.groovy
  171. +3 −4 src/groovy/de/dewarim/goblin/ticks/ITickListener.groovy
  172. +3 −4 src/groovy/de/dewarim/goblin/ticks/TickCommand.groovy
  173. +2 −3 src/groovy/de/dewarim/goblin/ticks/TickCommandType.groovy
  174. +2 −2 src/groovy/de/dewarim/goblin/ticks/TickMaster.groovy
  175. +1 −2 src/groovy/de/dewarim/goblin/ticks/TickResult.groovy
  176. +1 −1 src/groovy/de/dewarim/goblin/ticks/TickRunner.groovy
  177. +1 −1 src/groovy/de/dewarim/goblin/ticks/TickTestBean.groovy
  178. +2 −2 src/java/de/dewarim/goblin/ICombatScript.java
  179. +0 −1 src/java/de/dewarim/goblin/IEncounterScript.java
  180. +1 −1 src/java/de/dewarim/goblin/IProductionScript.java
  181. +8 −9 test/integration/de/dewarim/goblin/ticks/TickServiceSpec.groovy
  182. +1 −1 test/webtest/de/dewarim/goblin/production/ProductionWebTests.groovy
  183. +10 −10 web-app/status.txt
View
37 GoblinGrailsPlugin.groovy
@@ -2,14 +2,15 @@ class GoblinGrailsPlugin {
def version = "0.3.2"
def grailsVersion = "2.0 > *"
- def dependsOn = [:]
def pluginExcludes = [
- "grails-app/views/error.gsp"
+ "docs/**",
+ "grails-app/views/error.gsp",
+ "src/docs/**",
+ "src/templates/**",
+ "web-app/images/**"
]
def title = "Little Goblin Plugin"
- def author = "Ingo Wiarda"
- def authorEmail = "ingo_wiarda@dewarim.de"
def description = "Little Goblin is a browser game framework written in Grails."
def documentation = "http://littlegoblin.de"
@@ -20,32 +21,4 @@ class GoblinGrailsPlugin {
def issueManagement = [system: "Github", url: "https://github.com/dewarim/LittleGoblin/issues"]
def scm = [url: "https://github.com/dewarim/LittleGoblin"]
-
- def doWithWebDescriptor = { xml ->
-
- }
-
- def doWithSpring = {
-
- }
-
- def doWithDynamicMethods = { ctx ->
-
- }
-
- def doWithApplicationContext = { applicationContext ->
-
- }
-
- def onChange = { event ->
-
- }
-
- def onConfigChange = { event ->
-
- }
-
- def onShutdown = { event ->
-
- }
}
View
2 INSTALL.md
@@ -21,7 +21,7 @@ On Ubuntu, use: sudo apt-get install tomcat7
* Create a database "goblin" with user "goblin" and password "goblin" (for testing)
-* Download a database driver for MySQL if needed
+* Download a database driver for MySQL if needed
[http://dev.mysql.com/downloads/connector/j/5.1.html]
Put the mysql driver .jar-file into Tomcat's "lib" directory
(Postgres JDBC driver is included in the war file)
View
12 README.md
@@ -8,15 +8,15 @@ game environment as seen on the test server on http://schedim.de
## Getting started
For instructions to install the binary version, see: [INSTALL.md](INSTALL.md)
-
+
* Checkout the source code from Github:
-
+
git clone git@github.com:dewarim/LittleGoblin.git
-
+
* Edit goblin-config.example.groovy according to your database settings and serverURL
-
-* Start the application with
-
+
+* Start the application with
+
grails run-app
* Visit http://localhost:8080/goblin after the startup phase has completed.
View
52 grails-app/conf/BootStrap.groovy
@@ -72,23 +72,23 @@ class BootStrap {
def academyService
def grailsApplication
def tickService
-
+
// def camelContext
// def brokerService
def init = { servletContext ->
// currently disabled
// brokerService.start()
-// camelContext.addComponent("activemq", ActiveMQComponent.activeMQComponent("vm://localhost?broker.persistent=false"));
+// camelContext.addComponent("activemq", ActiveMQComponent.activeMQComponent("vm://localhost?broker.persistent=false"))
// ((CamelContext) camelContext).addRoutes (new GoblinRouteBuilder())
// camelContext.start()
-// ProducerTemplate template = camelContext.createProducerTemplate();
+// ProducerTemplate template = camelContext.createProducerTemplate()
// template.sendBody('activemq:learning', 'boo')
if (!UserAccount.list().isEmpty()) {
return
}
-
+
log.debug("LITTLE_GOBLIN_HOME: ${System.env.LITTLE_GOBLIN_HOME}")
log.debug("Facebook.config: ${grailsApplication.config.facebook}")
@@ -97,10 +97,10 @@ class BootStrap {
Role adminRole = new Role(description: 'Administrator', name: 'ROLE_ADMIN')
adminRole.save(flush: true, failOnError: true)
Role userRole = new Role(description: "User", name: 'ROLE_USER')
- userRole.save(flush: true, failOnError: true);
+ userRole.save(flush: true, failOnError: true)
log.debug("create admin user")
- UserAccount admin = new UserAccount(username: 'admin', userRealName: 'Admin', enabled: true);
+ UserAccount admin = new UserAccount(username: 'admin', userRealName: 'Admin', enabled: true)
admin.passwd = 'admin' // for local testing
admin.save(flush: true, failOnError: true)
UserRole adminAdminRole = new UserRole(user: admin, role: adminRole)
@@ -133,7 +133,7 @@ class BootStrap {
if (MobTemplate.list().size() == 0) {
initMobTemplates()
}
-
+
initTicks()
initCategories()
initItems(gob)
@@ -158,14 +158,14 @@ class BootStrap {
def tickListeners = ['skillService', 'productionService', 'meleeService']
if (Environment.current == Environment.TEST){
tickListeners.add('listenerTestBean')
- }
+ }
tickListeners.each{name ->
def tick = new Tick(name: "tick.service.$name", beanName:name)
tick.save()
}
tickService.initialize()
}
-
+
void initScripts(){
log.debug("create scripts")
def scripts = ['script.pickupItem': PickupItem.class, 'script.deliverItem': DeliverItem.class,
@@ -377,14 +377,14 @@ class BootStrap {
EquipmentSlotType body = EquipmentSlotType.findByName('slot.body')
ItemType cloth = new ItemType(name: 'armor.cloth', baseValue: 4)
cloth.save()
- RequiredSlot rs = new RequiredSlot(body, cloth);
+ RequiredSlot rs = new RequiredSlot(body, cloth)
rs.save()
EquipmentSlotType head = EquipmentSlotType.findByName('slot.head')
ItemType cap = new ItemType(name: 'armor.leather_cap', baseValue: 4)
cap.save()
- rs = new RequiredSlot(head, cap);
+ rs = new RequiredSlot(head, cap)
rs.save()
EquipmentSlotType hand = EquipmentSlotType.findByName('slot.hand')
@@ -392,11 +392,11 @@ class BootStrap {
shield.save()
rs = new RequiredSlot(hand, shield)
rs.save()
-
+
def armory = [cloth, cap, shield]
armory.each {armor ->
ItemCategory armorCat = new ItemCategory(armor, 'armor')
- armorCat.save()
+ armorCat.save()
}
}
@@ -420,7 +420,7 @@ class BootStrap {
redShroom.save()
ItemCategory mushroomCat = new ItemCategory(redShroom, 'mushroom')
mushroomCat.save()
-
+
ItemType blackShroom = new ItemType(name: 'item.mushroom.black', availability: 0, baseValue: 2)
blackShroom.save()
ItemCategory bsCat = new ItemCategory(blackShroom, 'mushroom')
@@ -428,11 +428,11 @@ class BootStrap {
// init items for products:
def ore = new ItemType(name: 'item.iron.ore', availability: 900, baseValue: 10, stackable: true)
- ore.save();
+ ore.save()
ItemCategory oreCat = new ItemCategory(ore, 'metal')
oreCat.save()
def iron = new ItemType(name: 'item.iron.bar', availability: 900, baseValue: 40, stackable: true)
- iron.save();
+ iron.save()
ItemCategory ironCat = new ItemCategory(iron, 'metal')
ironCat.save()
@@ -458,7 +458,7 @@ class BootStrap {
WeaponAttribute fire = new WeaponAttribute(damageModifier: 2.0, combatAttributeType: catFire)
fireWhip.addToCombatAttributes(fire)
fireWhip.save()
- RequiredSlot rs = new RequiredSlot(hand, fireWhip);
+ RequiredSlot rs = new RequiredSlot(hand, fireWhip)
rs.save()
CombatAttributeType catNormal = CombatAttributeType.findByName('attribute.normal')
@@ -469,7 +469,7 @@ class BootStrap {
baseValue: 5, combatDice: die)
shortSword.addToCombatAttributes(normalDamage)
shortSword.save()
- RequiredSlot rsSword = new RequiredSlot(hand, shortSword);
+ RequiredSlot rsSword = new RequiredSlot(hand, shortSword)
rsSword.save()
die = new Dice(sides: 6, amount: 2)
@@ -478,9 +478,9 @@ class BootStrap {
baseValue: 30, combatDice: die)
longSword.addToCombatAttributes(normalDamage)
longSword.save()
- RequiredSlot rsLongSword = new RequiredSlot(hand, longSword);
+ RequiredSlot rsLongSword = new RequiredSlot(hand, longSword)
rsLongSword.save()
- RequiredSlot rsLongSword2 = new RequiredSlot(hand, longSword);
+ RequiredSlot rsLongSword2 = new RequiredSlot(hand, longSword)
rsLongSword2.save()
die = new Dice(sides: 5, amount: 2, bonus: 2)
@@ -489,9 +489,9 @@ class BootStrap {
baseValue: 23, combatDice: die)
longStaff.addToCombatAttributes(normalDamage)
longStaff.save()
- RequiredSlot rsLongStaff = new RequiredSlot(hand, longStaff);
+ RequiredSlot rsLongStaff = new RequiredSlot(hand, longStaff)
rsLongStaff.save()
- RequiredSlot rsLongStaff2 = new RequiredSlot(hand, longStaff);
+ RequiredSlot rsLongStaff2 = new RequiredSlot(hand, longStaff)
rsLongSword2.save()
die = new Dice(sides: 1, amount: 1, bonus: 6)
@@ -502,7 +502,7 @@ class BootStrap {
def death = new WeaponAttribute(damageModifier: 2.0, combatAttributeType: catDeath)
toothpick.addToCombatAttributes death
toothpick.save()
- RequiredSlot rsPick = new RequiredSlot(hand, toothpick);
+ RequiredSlot rsPick = new RequiredSlot(hand, toothpick)
rsPick.save()
die = new Dice(sides: 4, amount: 1)
@@ -513,7 +513,7 @@ class BootStrap {
torch.addToCombatAttributes(torchFire)
torch.save()
RequiredSlot rsTorch = new RequiredSlot(hand, torch)
- rsTorch.save()
+ rsTorch.save()
def weapons = [fireWhip, shortSword, longSword, longStaff, toothpick, torch]
weapons.each {weapon ->
@@ -1070,7 +1070,7 @@ class BootStrap {
]
settings.each {k, v ->
- GlobalConfigEntry entry = new GlobalConfigEntry(name: k, entryValue: v);
+ GlobalConfigEntry entry = new GlobalConfigEntry(name: k, entryValue: v)
entry.save()
}
}
@@ -1089,4 +1089,4 @@ class BootStrap {
Help academyHelp = new Help(messageId: 'help.skillSets')
academyHelp.save()
}
-}
+}
View
63 grails-app/conf/BuildConfig.groovy
@@ -1,65 +1,54 @@
grails.servlet.version = "3.0"
-grails.project.class.dir = "target/classes"
-grails.project.test.class.dir = "target/test-classes"
-grails.project.test.reports.dir = "target/test-reports"
-//grails.project.war.file = "target/${appName}-${appVersion}.war"
+grails.project.work.dir = "target"
grails.project.target.level = 1.7
grails.project.source.level = 1.7
grails.project.war.file = "target/${appName}.war"
grails.project.dependency.resolution = {
- // inherit Grails' default dependencies
+
inherits( "global" ) {
- // uncomment to disable ehcache
- // excludes 'ehcache'
- excludes "xercesImpl", "xmlParserAPIs", "xml-apis", 'groovy';
+ excludes "xercesImpl", "xmlParserAPIs", "xml-apis", 'groovy'
}
- log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
+ log "warn"
+
repositories {
- mavenLocal()
- grailsRepo "http://grails.org/plugins"
grailsCentral()
- grailsPlugins()
- grailsHome()
-
- // snapshots-repos needed or webtest won't run:
-// mavenRepo 'http://webtest.canoo.com/webtest/
-// mavenRepo 'http://htmlunit.sourceforge.net/m2-repo-snapshots'
-
- // uncomment the below to enable remote dependency resolution
- // from public Maven repositories
-// mavenLocal()
+ mavenLocal()
mavenCentral()
-// mavenRepo "http://snapshots.repository.codehaus.org"
-// mavenRepo "http://repository.codehaus.org"
-// mavenRepo "http://download.java.net/maven/2/"
- //mavenRepo "http://repository.jboss.com/maven2/"
}
- dependencies {
- // specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.
- // runtime 'mysql:mysql-connector-java:5.1.5'
- runtime 'postgresql:postgresql:9.1-901.jdbc4'
+ dependencies {
+ runtime 'postgresql:postgresql:9.1-901.jdbc4', {
+ export = false
+ }
compile 'javax.mail:mail:1.4.5'
compile 'javax.activation:activation:1.1.1'
compile("org.codehaus.groovy.modules.http-builder:http-builder:0.5.2"){
excludes "groovy"
}
compile 'org.codehaus.gpars:gpars:1.0.0'
- test "org.spockframework:spock-grails-support:0.7-groovy-2.0"
+ test "org.spockframework:spock-grails-support:0.7-groovy-2.0", {
+ export = false
+ }
}
-
- plugins{
+
+ plugins{
// compile ":mail:1.0"
- runtime ":hibernate:$grailsVersion"
- build ":tomcat:$grailsVersion"
- compile ":release:2.2.0"
+ runtime ":hibernate:$grailsVersion", {
+ export = false
+ }
+ build ":tomcat:$grailsVersion", {
+ export = false
+ }
+ build ':release:2.2.0', ':rest-client-builder:1.0.3', {
+ export = false
+ }
runtime ":jquery:1.8.3"
runtime ":resources:1.1.6"
- compile ':spring-security-core:1.2.7.3'
+ compile ':spring-security-core:1.2.7.3'
compile ":webxml:1.4.1"
test(":spock:0.7") {
exclude "spock-grails-support"
+ export = false
}
}
-
}
View
2 grails-app/conf/de/dewarim/goblin/filters/UserFilters.groovy
@@ -19,7 +19,7 @@ class UserFilters {
}
public static boolean isAjax(request) {
- return "XMLHttpRequest".equals(request.getHeader("X-Requested-With"));
+ return "XMLHttpRequest".equals(request.getHeader("X-Requested-With"))
}
View
5 grails-app/conf/spring/resources.groovy
@@ -35,7 +35,6 @@ beans = {
// }
// learningDelayer(de.dewarim.goblin.camel.LearningDelayer)
-
+
listenerTestBean(TickTestBean)
-
-}
+}
View
50 grails-app/controllers/de/dewarim/goblin/AcademyController.groovy
@@ -1,10 +1,10 @@
package de.dewarim.goblin
import grails.plugins.springsecurity.Secured
-import de.dewarim.goblin.town.Academy
-import de.dewarim.goblin.town.AcademySkillSet
import groovy.xml.MarkupBuilder
import de.dewarim.goblin.pc.skill.LearningQueueElement
+import de.dewarim.goblin.town.Academy
+import de.dewarim.goblin.town.AcademySkillSet
class AcademyController extends BaseController {
transient jmsTemplate
@@ -42,11 +42,12 @@ class AcademyController extends BaseController {
def academy = Academy.get(params.academy)
if(! academy){
flash.message = message(code: 'error.academy.not_found')
- return redirect(controller: 'town', action: 'show')
+ redirect(controller: 'town', action: 'show')
+ return
}
if (academyService.checkPlayerAccess(pc, academy)) {
- Map<AcademySkillSet, LearningQueueElement> queue = new HashMap<AcademySkillSet, LearningQueueElement>()
+ Map<AcademySkillSet, LearningQueueElement> queue = [:]
pc.learningQueueElements.each{
queue.put(it.academySkillSet, it)
}
@@ -54,15 +55,15 @@ class AcademyController extends BaseController {
return [
pc: pc,
queue:queue,
- academy: academy,
+ academy: academy,
academySkillSets:academyService.filterSkillSets(pc, academy)
]
}
else {
flash.message = message(code: 'error.academy.no.member')
- return redirect(controller: 'town', action: 'show')
+ redirect(controller: 'town', action: 'show')
+ return
}
-
}
/**
@@ -72,9 +73,10 @@ class AcademyController extends BaseController {
def describe() {
Academy academy = Academy.get(params.academy)
if(! academy){
- return render(status:503, text:message(code:'error.academy.not_found'))
+ render(status:503, text:message(code:'error.academy.not_found'))
+ return
}
- return render(template:"/academy/academy_description", model:[academy:academy])
+ render(template:"/academy/academy_description", model:[academy:academy])
}
/**
@@ -103,23 +105,27 @@ class AcademyController extends BaseController {
def academy = Academy.get(params.academy)
if(! academy){
flash.message = message(code: 'error.academy.not_found')
- return redirect(controller: 'town', action: 'show')
+ redirect(controller: 'town', action: 'show')
+ return
}
if (academyService.checkPlayerAccess(pc, academy)) {
AcademySkillSet ass = AcademySkillSet.get(params.ass)
if(! ass ){
flash.message = message(code: 'error.skillset.not.found')
- return redirect(controller:'town', action:'show')
+ redirect(controller:'town', action:'show')
+ return
}
def academySkillSets = academyService.filterSkillSets(pc, academy)
if(! academySkillSets.find{it.equals(ass)}){
flash.message = message(code: 'error.skillset.foreign')
- return redirect(controller:'town', action:'show')
+ redirect(controller:'town', action:'show')
+ return
}
def alreadyLearning = pc.learningQueueElements.find{it.academySkillSet.equals(ass)}
if(alreadyLearning){
flash.message = message(code: 'error.already.learning')
- return redirect(controller:'academy', action:'show', params:[academy:params.academy])
+ redirect(controller:'academy', action:'show', params:[academy:params.academy])
+ return
}
// time to pay for this ass:
@@ -132,11 +138,13 @@ class AcademyController extends BaseController {
flash.message = message(code:'error.insufficient.funds')
}
- return redirect(action:'show', controller:'academy', params:[academy:academy.id])
+ redirect(action:'show', controller:'academy', params:[academy:academy.id])
+ return
}
else {
flash.message = message(code: 'error.academy.no.member')
- return redirect(controller: 'town', action: 'show')
+ redirect(controller: 'town', action: 'show')
+ return
}
}
@@ -147,21 +155,23 @@ class AcademyController extends BaseController {
LearningQueueElement queueElement = LearningQueueElement.get(params.queueElement)
if(! queueElement){
flash.message = message(code:'error.queueElement.not_found')
- return redirect(controller:'town', action:'show')
+ redirect(controller:'town', action:'show')
+ return
}
if(pc.learningQueueElements.contains(queueElement)){
def ass = queueElement.academySkillSet
academyService.refundLearningCost queueElement
pc.removeFromLearningQueueElements queueElement
ass.removeFromLearningQueueElements queueElement
- queueElement.delete()
- return redirect(controller:'academy', action:'show', params:[academy:ass.academy.id])
+ queueElement.delete()
+ redirect(controller:'academy', action:'show', params:[academy:ass.academy.id])
+ return
}
else{
flash.message = message(code:'error.object.foreign')
- return redirect(controller:'town', action:'show')
+ redirect(controller:'town', action:'show')
+ return
}
-
}
protected String createLearningMessage(LearningQueueElement queueElement){
View
4 grails-app/controllers/de/dewarim/goblin/BaseController.groovy
@@ -38,7 +38,7 @@ class BaseController {
}
protected UserAccount fetchUser() {
- return (UserAccount) springSecurityService.currentUser
+ return springSecurityService.currentUser
}
/**
@@ -54,7 +54,7 @@ class BaseController {
if (!pc) {
throw new RuntimeException('error.no.pc')
}
- def item = (Item) inputValidationService.checkObject(Item.class, params.item, true)
+ Item item = inputValidationService.checkObject(Item, params.item, true)
if (!item) {
throw new RuntimeException('error.item_not_found')
}
View
2 grails-app/controllers/de/dewarim/goblin/CaptchaController.groovy
@@ -20,7 +20,7 @@ class CaptchaController {
int l = SOURCECHARS.length()
StringBuilder b = new StringBuilder()
6.times {
- int r = (int)(Math.random() * l)
+ int r = Math.random() * l
b.append(SOURCECHARS.charAt(r))
}
View
48 grails-app/controllers/de/dewarim/goblin/FightController.groovy
@@ -1,32 +1,30 @@
-package de.dewarim.goblin;
-
-import de.dewarim.goblin.mob.Mob
-import de.dewarim.goblin.mob.MobTemplate
-import de.dewarim.goblin.quest.Quest
-import de.dewarim.goblin.item.Item
+package de.dewarim.goblin
import grails.plugins.springsecurity.Secured
-
import de.dewarim.goblin.combat.Combat
+import de.dewarim.goblin.item.Item
+import de.dewarim.goblin.mob.Mob
+import de.dewarim.goblin.mob.MobTemplate
import de.dewarim.goblin.pc.PlayerCharacter
+import de.dewarim.goblin.quest.Quest
-
+@Secured(['ROLE_USER'])
class FightController extends BaseController {
-
+
def treasureService
def fightService
/*
* Show opponent, option fight or flee.
*/
- @Secured(['ROLE_USER'])
def index() {
def user = fetchUser()
Combat combat = Combat.get(params.combat)
if (!combat) {
flash.message = message(code: 'error.combat.not_found')
- return redirect(action: 'start', controller: 'portal')
+ redirect(action: 'start', controller: 'portal')
+ return
}
log.debug("pc.id: " + combat.playerCharacter.id)
def pc = combat.playerCharacter
@@ -45,31 +43,33 @@ class FightController extends BaseController {
]
}
- MobTemplate selectRandomMobType() {
+ private MobTemplate selectRandomMobType() {
List<MobTemplate> mtList = MobTemplate.list()
return mtList.get((Integer) (Math.random() * mtList.size()))
}
- @Secured(['ROLE_USER'])
def flee() {
def user = fetchUser()
Combat combat = Combat.get(params.combat)
if (!combat) {
flash.message = message(code: 'error.combat.not_found')
- return redirect(action: 'start', controller: 'portal')
+ redirect(action: 'start', controller: 'portal')
+ return
}
def pc = combat.playerCharacter
if (!pc.user.equals(user)) {
// prevent cheating / using other player's combat.
flash.message = message(code: 'error.foreign.object')
- return redirect(action: 'start', controller: 'portal')
+ redirect(action: 'start', controller: 'portal')
+ return
}
if (!pc.currentQuest) {
// pc has no current quest - probably reloaded this page.
- return redirect(action: 'show', controller: 'town', params: [pc: pc.id])
+ redirect(action: 'show', controller: 'town', params: [pc: pc.id])
+ return
}
combat.finished = new Date()
@@ -88,7 +88,6 @@ class FightController extends BaseController {
/*
* Show fight result
*/
- @Secured(['ROLE_USER'])
def fight() {
def user = fetchUser()
@@ -100,13 +99,15 @@ class FightController extends BaseController {
Combat.withTransaction {
combat = Combat.lock(params.combat)
if (!combat) {
- return redirect(controller: 'portal', action: 'start')
+ redirect(controller: 'portal', action: 'start')
+ return
}
pc = combat.playerCharacter
if (!pc.user.equals(user)) {// make sure it is this user's combat
flash.message = message(code: 'error.foreign.object')
- return redirect(action: 'start', controller: 'portal')
+ redirect(action: 'start', controller: 'portal')
+ return
}
mob = combat.fetchFirstMob()
String action
@@ -119,7 +120,8 @@ class FightController extends BaseController {
}
if (action) {
- return redirect(action: action, params: [pc: pc.id, mob: mob.id, combat: combat.id])
+ redirect(action: action, params: [pc: pc.id, mob: mob.id, combat: combat.id])
+ return
}
}
return [pc: pc,
@@ -128,7 +130,6 @@ class FightController extends BaseController {
]
}
- @Secured(['ROLE_USER'])
def victory() {
// TODO: set mob to dead.
// TODO: add mob to pc.history
@@ -138,13 +139,13 @@ class FightController extends BaseController {
def mob = Mob.get(params.mob)
if (!pc.currentCombat) {
- return redirect(controller: 'town', action: 'show', param: [pc: pc.id])
+ redirect(controller: 'town', action: 'show', param: [pc: pc.id])
+ return
}
pc.currentCombat.finished = new Date()
pc.currentCombat = null
-
pc.xp = pc.xp + mob.xpValue
pc.victories = pc.victories + 1
@@ -174,7 +175,6 @@ class FightController extends BaseController {
/*
* Charakter is dead, show death message and high score.
*/
- @Secured(['ROLE_USER'])
def death() {
def user = fetchUser()
View
49 grails-app/controllers/de/dewarim/goblin/GuildController.groovy
@@ -3,6 +3,7 @@ package de.dewarim.goblin
import grails.plugins.springsecurity.Secured
import de.dewarim.goblin.guild.Guild
+@Secured(['ROLE_USER'])
class GuildController extends BaseController{
def academyService
@@ -11,7 +12,6 @@ class GuildController extends BaseController{
/**
* Main overview of guilds
*/
- @Secured(['ROLE_USER'])
def index() {
def pc = fetchPc()
@@ -25,18 +25,19 @@ class GuildController extends BaseController{
]
}
- @Secured(['ROLE_USER'])
def show() {
def pc = fetchPc()
def guild = Guild.get(params.guild)
if(! guild){
flash.message = message(code:'error.guild.not_found')
- return redirect(controller:'town', action:'index')
+ redirect(controller:'town', action:'index')
+ return
}
if(! guildMemberService.checkMembership(pc, guild)){
flash.message = message(code:'error.guild.no.member')
- return redirect(controller:'guild', action:'show')
+ redirect(controller:'guild', action:'show')
+ return
}
return [
@@ -45,7 +46,6 @@ class GuildController extends BaseController{
]
}
- @Secured(['ROLE_USER'])
def showMyGuilds() {
def pc = fetchPc()
@@ -61,56 +61,56 @@ class GuildController extends BaseController{
/**
* Join a guild
*/
- @Secured(['ROLE_USER'])
def join() {
def pc = fetchPc()
Guild guild = Guild.get(params.guild)
if(! guild){
flash.message = message(code:'error.guild.not.found')
- return redirect(action:'index', controller:'guild')
+ redirect(action:'index', controller:'guild')
+ return
}
if( guildMemberService.checkMembership(pc, guild)){
flash.message = message(code:'error.guild.is.member')
- return redirect (action:'index', controller:'guild')
+ redirect(action:'index', controller:'guild')
+ return
}
if( pc.gold < guild.entryFee){
flash.message = message(code:'error.insufficient.gold')
- return redirect(action:'index', controller:'guild')
+ redirect(action:'index', controller:'guild')
+ return
}
else{
pc.gold = pc.gold - guild.entryFee
}
- // setup guild relationships
+ // setup guild relationships
guildMemberService.joinGuild(pc,guild)
// add AcademyLevels
academyService.joinGuild(pc,guild)
-
flash.message = message(code:'guild.join.success', args:[message(code:guild.name)])
- return redirect(action:'show', controller:'guild',params:[pc:pc.id, guild:guild.id])
+ redirect(action:'show', controller:'guild',params:[pc:pc.id, guild:guild.id])
+ return
}
-
-
-
/**
* Leave a guild
*/
- @Secured(['ROLE_USER'])
def leave() {
def pc = fetchPc()
Guild guild = Guild.get(params.guild)
if(! guild){
flash.message = message(code:'error.guild.not.found')
- return redirect(action:'index', controller:'guild')
+ redirect(action:'index', controller:'guild')
+ return
}
if( ! guildMemberService.checkMembership(pc, guild) ){
flash.message = message(code:'error.guild.no.member')
- return redirect(action:'index', controller:'guild')
+ redirect(action:'index', controller:'guild')
+ return
}
// check if the PC is expelled from one or more academies:
@@ -120,14 +120,13 @@ class GuildController extends BaseController{
guildMemberService.leaveGuild(pc,guild)
flash.message = message(code:'guild.leave.success', args:[message(code:guild.name)])
- return redirect(action:'index', controller:'guild',params:[pc:pc.id])
+ redirect(action:'index', controller:'guild',params:[pc:pc.id])
+ return
}
-
/**
* List guilds [Ajax]
*/
- @Secured(['ROLE_USER'])
def list() {
def pc = fetchPc()
@@ -143,16 +142,14 @@ class GuildController extends BaseController{
)
}
- @Secured(['ROLE_USER'])
def describe() {
def pc = fetchPc()
Guild guild = Guild.get(params.guild)
if(! guild){
- return render(status:503, text:message(code:'error.guild.not_found'))
+ render(status:503, text:message(code:'error.guild.not_found'))
+ return
}
- return render(template:"/guild/guild_description", model:[guild:guild])
+ render(template:"/guild/guild_description", model:[guild:guild])
}
-
-
}
View
26 grails-app/controllers/de/dewarim/goblin/HelpController.groovy
@@ -5,26 +5,24 @@ package de.dewarim.goblin
* Alternatives would include:
* load help from database
* load help from external (template) file
- * Currently, using templates is easier and very flexible.
+ * Currently, using templates is easier and very flexible.
*/
class HelpController {
- def summonHelp() {
- String messageId = params.messageId
+ def summonHelp(String messageId) {
Help help = Help.findByMessageId(messageId)
if(help){
- return render(text:message(code:messageId))
+ render(text:message(code:messageId))
+ return
}
- else{
- log.debug("Unidentified template: ${messageId?.encodeAsHTML()}")
- def tryTranslation = message(code:messageId.decodeURL())
- if(tryTranslation.equals(messageId)){
- return render(text:message(code:'help.not.found'))
- }
- else{
- return render(text:tryTranslation)
- }
+
+ log.debug("Unidentified template: ${messageId?.encodeAsHTML()}")
+ def tryTranslation = message(code:messageId.decodeURL())
+ if(tryTranslation.equals(messageId)){
+ render(text:message(code:'help.not.found'))
+ return
}
- }
+ render(text:tryTranslation)
+ }
}
View
84 grails-app/controllers/de/dewarim/goblin/ItemController.groovy
@@ -1,14 +1,11 @@
-package de.dewarim.goblin;
-
+package de.dewarim.goblin
import grails.plugins.springsecurity.Secured
-
-import de.dewarim.goblin.item.Item;
-
-
import de.dewarim.goblin.combat.Combat
+import de.dewarim.goblin.item.Item
import de.dewarim.goblin.shop.Shop
+@Secured(['ROLE_USER'])
class ItemController extends BaseController {
def featureService
@@ -17,7 +14,6 @@ class ItemController extends BaseController {
/**
* Use an item belonging to the player in the context of a combat setting.
*/
- @Secured(['ROLE_USER'])
def useItem() {
def user = fetchUser()
@@ -27,11 +23,13 @@ class ItemController extends BaseController {
// check input parameters
if (!combat) {
flash.message = message(code: 'error.combat_not_found')
- return redirect(action: 'show', controller: 'town')
+ redirect(action: 'show', controller: 'town')
+ return
}
if (!combat.playerCharacter.user.equals(user)) {
flash.message = message(code: 'error.wrong_combat')
- return redirect(action: 'show', controller: 'town')
+ redirect(action: 'show', controller: 'town')
+ return
}
def pc = combat.playerCharacter
@@ -41,12 +39,14 @@ class ItemController extends BaseController {
if (!pc.equals(item.owner)) {
// tried to use an item that does not belong to him.
flash.message = message(code: "error.item_not_found")
- return redirect(action: 'fight', controller: 'fight', params: [combat: combat.id])
+ redirect(action: 'fight', controller: 'fight', params: [combat: combat.id])
+ return
}
if (!itemType.itemTypeFeatures?.find {it.feature.id == itemFeature.id}) {
// tried to use an unmapped feature.
flash.message = message(code: "error.feature_not_found")
- return redirect(action: 'fight', controller: 'fight', params: [combat: combat.id])
+ redirect(action: 'fight', controller: 'fight', params: [combat: combat.id])
+ return
}
// Is the item usable? Then execute its script.
@@ -64,50 +64,57 @@ class ItemController extends BaseController {
}
else {
flash.message = message(code: 'error.no_use_left')
-// return redirect(action:'fight', controller:'fight', params:[combat:combat.id])
+// redirect(action:'fight', controller:'fight', params:[combat:combat.id])
+// return
}
- return redirect(action: 'fight', controller: 'fight', params: [combat: combat.id])
+ redirect(action: 'fight', controller: 'fight', params: [combat: combat.id])
+ return
}
- @Secured(['ROLE_USER'])
def equipItem() {
def pc = fetchPc()
try {
if (!pc) {
- return render(status: 503, text: message(code: 'error.no.pc'))
+ render(status: 503, text: message(code: 'error.no.pc'))
+ return
}
Item item = Item.get(params.item)
if (!item) {
- return render(status: 503, text: message(code: 'error.item.not_found'))
+ render(status: 503, text: message(code: 'error.item.not_found'))
+ return
}
if (!pc.equals(item.owner)) {
- return render(status: 503, text: message(code: 'error.wrong_owner'))
+ render(status: 503, text: message(code: 'error.wrong_owner'))
+ return
}
if (!(item.type.requiredSlots?.size() > 0)) {
- return render(status: 503, text: message(code: 'error.item.unequippable'))
+ render(status: 503, text: message(code: 'error.item.unequippable'))
+ return
}
if (item.equipped) {
- return render(status: 503, text: message(code: 'error.item.is_equipped'))
+ render(status: 503, text: message(code: 'error.item.is_equipped'))
+ return
}
log.debug("Trying to equip item: ${item.type.name}")
if (!pc.equipItem(item)) {
- return render(status: 503, text: message(code: 'error.slots.full'))
+ render(status: 503, text: message(code: 'error.slots.full'))
+ return
}
if (params.shop) {
log.debug("found shop: ${params.shop}")
def shop = inputValidationService.checkObject(Shop.class, params.shop)
- return render(template: '/shared/equipment', model:[pc:pc, shop:shop])
+ render(template: '/shared/equipment', model:[pc:pc, shop:shop])
+ return
}
- return render(template: 'inventory', model: [pc: pc])
+ render(template: 'inventory', model: [pc: pc])
}
catch (Exception e) {
- return render(status: 500, text:message(code:'error.equip.fail', args:[message(code:e.message)]))
+ render(status: 500, text:message(code:'error.equip.fail', args:[message(code:e.message)]))
}
}
- @Secured(['ROLE_USER'])
def unequipItem() {
try {
def pc = fetchPc()
@@ -126,30 +133,28 @@ class ItemController extends BaseController {
}
if(params.sideInventory){
// render left side inventory instead of main inventory
- return render(template: '/shared/sideInventory', model: [pc: pc, shop: shop])
+ render(template: '/shared/sideInventory', model: [pc: pc, shop: shop])
}
else{
- return render(template: 'inventory', model: [pc: pc, shop: shop])
+ render(template: 'inventory', model: [pc: pc, shop: shop])
}
}
catch (Exception e) {
log.debug("failed to unequip item because of:", e)
- return render(status: 503, text: message(code: e.getMessage()))
+ render(status: 503, text: message(code: e.getMessage()))
}
}
-
- @Secured(['ROLE_USER'])
def showInventory() {
// TODO: if pc is on a quest or in combat, prevent him from moving stuff from home to person.
def pc = fetchPc()
if (!pc) {
- return redirect(controller: 'portal', action: 'start')
+ redirect(controller: 'portal', action: 'start')
+ return
}
return [pc: pc]
}
- @Secured(['ROLE_USER'])
def renderInventory() {
def pc = fetchPc()
// render tem
@@ -160,7 +165,6 @@ class ItemController extends BaseController {
* To simulate a fleet of space ships, each carrying items and storing them at different planets, this system
* would need to be considerably expanded.
*/
- @Secured(['ROLE_USER'])
def carryItem() {
try {
def pc = fetchPc()
@@ -168,7 +172,8 @@ class ItemController extends BaseController {
if (item.location == ItemLocation.ON_PERSON) {
// nothing to do.
log.debug("item to carry is already 'on person'.")
- return render(template: 'inventory', model: [pc: pc])
+ render(template: 'inventory', model: [pc: pc])
+ return
}
def amount = Math.abs(inputValidationService.checkAndEncodeInteger(params, "amount", 'item.amount'))
@@ -194,15 +199,14 @@ class ItemController extends BaseController {
else {
item.location = ItemLocation.ON_PERSON
}
- return render(template: 'inventory', model: [pc: pc])
+ render(template: 'inventory', model: [pc: pc])
}
catch (Exception e) {
log.debug("failed to carry item: ", e)
- return render(status: 503, text: message(code: e.message))
+ render(status: 503, text: message(code: e.message))
}
}
- @Secured(['ROLE_USER'])
def dropItem() {
try {
def pc = fetchPc()
@@ -210,7 +214,8 @@ class ItemController extends BaseController {
if (item.location == ItemLocation.AT_HOME) {
// nothing to do.
log.debug("item to drop is already 'at_home'")
- return render(template: 'inventory', model: [pc: pc])
+ render(template: 'inventory', model: [pc: pc])
+ return
}
def amount = Math.abs(inputValidationService.checkAndEncodeInteger(params, "amount", 'item.amount'))
amount = amount > item.amount ? item.amount : amount
@@ -235,12 +240,11 @@ class ItemController extends BaseController {
item.location = ItemLocation.AT_HOME
}
- return render(template: 'inventory', model: [pc: pc])
+ render(template: 'inventory', model: [pc: pc])
}
catch (Exception e) {
log.debug("failed to drop item: ", e)
- return render(status: 503, text: message(code: e.message))
+ render(status: 503, text: message(code: e.message))
}
}
-
}
View
56 grails-app/controllers/de/dewarim/goblin/MeleeController.groovy
@@ -3,11 +3,11 @@ package de.dewarim.goblin
import grails.plugins.springsecurity.Secured
import de.dewarim.goblin.combat.Melee
import de.dewarim.goblin.combat.MeleeFighter
-import de.dewarim.goblin.combat.MeleeAction
-import de.dewarim.goblin.pc.PlayerCharacter
import de.dewarim.goblin.item.Item
import de.dewarim.goblin.item.ItemTypeFeature
+import de.dewarim.goblin.pc.PlayerCharacter
+@Secured(['ROLE_USER'])
class MeleeController extends BaseController {
def meleeService
@@ -17,11 +17,11 @@ class MeleeController extends BaseController {
* Show list of current melee fighters and allow player to join in.
* If now melee is running, the player may register for the next round.
*/
- @Secured(['ROLE_USER'])
def index() {
def pc = fetchPc()
if (!pc) {
- return redirect(controller: 'portal', action: 'start')
+ redirect(controller: 'portal', action: 'start')
+ return
}
return fetchViewParameters(pc)
}
@@ -30,17 +30,18 @@ class MeleeController extends BaseController {
* Join a melee round. There should always be one melee in status RUNNING or WAITING, which the
* player may join.
*/
- @Secured(['ROLE_USER'])
def join() {
def pc = fetchPc()
if (!pc) {
flash.message = message(code: 'melee.join.failed')
- return redirect(controller: 'melee', action: 'index')
+ redirect(controller: 'melee', action: 'index')
+ return
}
if (pc.currentMelee) {
flash.message = message(code: 'melee.join.already')
- return redirect(controller: 'melee', action: index)
+ redirect(controller: 'melee', action: index)
+ return
}
def melee = meleeService.findOrCreateMelee()
@@ -50,22 +51,24 @@ class MeleeController extends BaseController {
}
else {
flash.message = message(code: 'melee.join.not.again')
- return redirect(controller: 'melee', action: index)
+ redirect(controller: 'melee', action: index)
+ return
}
if (melee.status == MeleeStatus.WAITING) {
- return redirect(controller: 'melee', action: 'index')
+ redirect(controller: 'melee', action: 'index')
+ return
}
else {
- return redirect(controller: 'melee', action: 'show',
+ redirect(controller: 'melee', action: 'show',
params: [pc: pc, melee: melee, fighters: meleeService.listFighters(melee)])
+ return
}
}
/**
* Leave a melee round. A player may leave at any time.
*/
- @Secured(['ROLE_USER'])
def leave() {
def pc = fetchPc()
if (!pc || pc.currentMelee == null) {
@@ -75,10 +78,10 @@ class MeleeController extends BaseController {
meleeService.leaveMelee(pc, pc.currentMelee)
flash.message = message(code: 'melee.left.melee')
}
- return redirect(controller: 'melee', action: 'index')
+ redirect(controller: 'melee', action: 'index')
+ return
}
- @Secured(['ROLE_USER'])
def useItem() {
def pc = fetchPc()
try {
@@ -91,7 +94,7 @@ class MeleeController extends BaseController {
if (!itemFeature) {
throw new RuntimeException('melee.action.fail')
}
- def ids = itemFeature.split('__');
+ def ids = itemFeature.split('__')
if (ids.size() != 2) {
throw new RuntimeException('melee.action.fail')
}
@@ -110,40 +113,39 @@ class MeleeController extends BaseController {
// ok, useItem request seems valid:
meleeService.addUseItemAction(pc, adversary, item, itemTypeFeature)
- return render(template: 'chooseAction', model: fetchViewParameters(pc))
+ render(template: 'chooseAction', model: fetchViewParameters(pc))
}
catch (Exception e) {
if (pc) {
def p = fetchViewParameters(pc)
p.put('meleeMessage', message(code: e.getMessage()))
- return render(template: 'chooseAction', model: p)
+ render(template: 'chooseAction', model: p)
}
else {
- return render(status: 503, text: message(code: e.getMessage()))
+ render(status: 503, text: message(code: e.getMessage()))
}
}
}
- @Secured(['ROLE_USER'])
def updateActions() {
def pc = fetchPc()
if (!pc) {
- return render(status: 503, text: message(code: 'melee.error'))
+ render(status: 503, text: message(code: 'melee.error'))
+ return
}
- return render(template: 'chooseAction', model: fetchViewParameters(pc))
+ render(template: 'chooseAction', model: fetchViewParameters(pc))
}
- @Secured(['ROLE_USER'])
def updateFighterList() {
def pc = fetchPc()
if (!pc) {
- return render(status: 503, text: message(code: 'melee.error'))
+ render(status: 503, text: message(code: 'melee.error'))
+ return
}
Melee melee = meleeService.findOrCreateMelee()
- return render(template: 'fighters', model: [pc: pc, fighters: meleeService.listFighters(melee)])
+ render(template: 'fighters', model: [pc: pc, fighters: meleeService.listFighters(melee)])
}
- @Secured(['ROLE_USER'])
def attack() {
try {
def pc = fetchPc()
@@ -172,12 +174,10 @@ class MeleeController extends BaseController {
p = fetchViewParameters(pc)
p.put('meleeMessage', 'melee.adversary.missing')
}
- return render(template: 'chooseAction', model: p)
-
-
+ render(template: 'chooseAction', model: p)
}
catch (Exception e) {
- return render(status: 503, text: message(code: e.getMessage()))
+ render(status: 503, text: message(code: e.getMessage()))
}
}
View
47 grails-app/controllers/de/dewarim/goblin/PlayerCharacterController.groovy
@@ -1,13 +1,13 @@
-package de.dewarim.goblin;
+package de.dewarim.goblin
import grails.plugins.springsecurity.Secured
import de.dewarim.goblin.pc.PlayerCharacter
+@Secured(['ROLE_USER'])
class PlayerCharacterController extends BaseController{
-
+
def playerMessageService
-
- @Secured(['ROLE_USER'])
+
def show() {
def pc = fetchPc()
@@ -18,23 +18,26 @@ class PlayerCharacterController extends BaseController{
]
}
- @Secured(['ROLE_USER'])
def save() {
def user = fetchUser()
if(! params.name){
- return redirect(controller:'portal', action:'start', params:[createError:'pc.name.empty'])
+ redirect(controller:'portal', action:'start', params:[createError:'pc.name.empty'])
+ return
}
params.name = params.name.encodeAsHTML() // do not allow arbitrary HTML sequences.
if(params.name.length() > 32){
- return redirect(controller:'portal', action:'start', params:[createError:'pc.name.too_long'])
+ redirect(controller:'portal', action:'start', params:[createError:'pc.name.too_long'])
+ return
}
if(params.name.length() < 3){
- return redirect(controller:'portal', action:'start', params:[createError:'pc.name.too_short'])
+ redirect(controller:'portal', action:'start', params:[createError:'pc.name.too_short'])
+ return
}
def checkName = PlayerCharacter.findByName(params.name)
if(checkName){
- return redirect(controller:'portal', action:'start', params:[createError:'pc.name.exists'])
+ redirect(controller:'portal', action:'start', params:[createError:'pc.name.exists'])
+ return
}
PlayerCharacter pc = new PlayerCharacter(name:params.name)
@@ -42,24 +45,24 @@ class PlayerCharacterController extends BaseController{
if(pc.save(flush:true)){
pc.initializePlayerCharacter()
flash.message = message(code:"pc.create.success", args:[pc.name])
- return redirect(controller:'town', action:'show',params:[pc:pc.id] )
+ redirect(controller:'town', action:'show',params:[pc:pc.id] )
+ return
}
- else{
- return redirect(controller:'portal', action:'start')
+ else{
+ redirect(controller:'portal', action:'start')
+ return
}
-
}
- @Secured(['ROLE_USER'])
def editDescription() {
def pc = fetchPc()
if(! pc){
- return render(status:503, text:message(code:'error.player_not_found'))
+ render(status:503, text:message(code:'error.player_not_found'))
+ return
}
- return render(template:'/playerCharacter/editDescription', model:[pc:pc])
+ render(template:'/playerCharacter/editDescription', model:[pc:pc])
}
- @Secured(['ROLE_USER'])
def saveDescription() {
def pc = fetchPc()
if(! pc){
@@ -71,27 +74,25 @@ class PlayerCharacterController extends BaseController{
else{
pc.description = params.description
}
- return render(template:'/playerCharacter/showDescription', model:[pc:pc])
+ render(template:'/playerCharacter/showDescription', model:[pc:pc])
}
- @Secured(['ROLE_USER'])
def fetchMessages() {
def pc = fetchPc()
def pcMessages = null
if(pc){
pcMessages = playerMessageService.fetchPlayerMessages(pc)
}
- return render(template:'/shared/playerMessages', model:[pcMessages:pcMessages, pc:pc])
+ render(template:'/shared/playerMessages', model:[pcMessages:pcMessages, pc:pc])
}
- @Secured(['ROLE_USER'])
def fetchEquipment() {
def pc = fetchPc()
if(pc){
- return render(template: '/shared/equipment', model:[pc:pc])
+ render(template: '/shared/equipment', model:[pc:pc])
}
else{
- return render(status:500, text:'error.player.not.found')
+ render(status:500, text:'error.player.not.found')
}
}
}
View
8 grails-app/controllers/de/dewarim/goblin/PostOfficeController.groovy
@@ -1,10 +1,10 @@
package de.dewarim.goblin
import grails.plugins.springsecurity.Secured
-
import de.dewarim.goblin.item.Item
import de.dewarim.goblin.pc.PlayerCharacter
+@Secured(['ROLE_USER'])
class PostOfficeController extends BaseController {
def postOfficeService
@@ -12,11 +12,11 @@ class PostOfficeController extends BaseController {
/**
* Main overview of post office
*/
- @Secured(['ROLE_USER'])
def index() {
def pc = fetchPc()
if(! pc){
- return redirect(controller: 'portal', action: 'start')
+ redirect(controller: 'portal', action: 'start')
+ return
}
def itemList = pc.items.sort {message(code:it.type.name)}
return [pc: pc,
@@ -24,7 +24,6 @@ class PostOfficeController extends BaseController {
]
}
- @Secured(['ROLE_USER'])
def sendItem() {
def pc = fetchPc()
try {
@@ -65,7 +64,6 @@ class PostOfficeController extends BaseController {
}
}
- @Secured(['ROLE_USER'])
def loadInventory() {
def pc = fetchPc()
if(! pc){
View
59 grails-app/controllers/de/dewarim/goblin/ProductionController.groovy
@@ -1,13 +1,14 @@
package de.dewarim.goblin
import grails.plugins.springsecurity.Secured
-import de.dewarim.goblin.pc.crafting.ProductCategory
import de.dewarim.goblin.pc.crafting.Product
+import de.dewarim.goblin.pc.crafting.ProductCategory
import de.dewarim.goblin.pc.crafting.ProductionJob
/**
* A product is something a player can create, given the necessary materials and skill requirements.
*/
+@Secured(['ROLE_USER'])
class ProductionController extends BaseController{
def productionService
@@ -15,29 +16,30 @@ class ProductionController extends BaseController{
/**
* Show the list of available product categories.
*/
- @Secured(['ROLE_USER'])
def workshop() {
def pc = fetchPc()
if(! pc){
- return redirect(action:'start', controller:'portal')
+ redirect(action:'start', controller:'portal')
+ return
}
def categories = ProductCategory.list()
-
+
return [categories:categories,
pc:pc
]
}
- @Secured(['ROLE_USER'])
def listProducts() {
def pc = fetchPc()
if(! pc){
- return redirect(action:'start', controller:'portal')
+ redirect(action:'start', controller:'portal')
+ return
}
def category = ProductCategory.get(params.category)
if(! category){
flash.message = message(code:'error.missing.category')
- return redirect(action:'show', controller:'town')
+ redirect(action:'show', controller:'town')
+ return
}
// return a list of all products which the user may create
@@ -53,11 +55,11 @@ class ProductionController extends BaseController{
]
}
- @Secured(['ROLE_USER'])
def selectComponents() {
def pc = fetchPc()
if(! pc){
redirect(action:'start', controller:'portal')
+ return
}
def product = Product.get(params.product)
if(product &&
@@ -79,21 +81,20 @@ class ProductionController extends BaseController{
}
else{
flash.message = message(code:'error.missing.product')
- return redirect(action:'workshop', controller:'production')
+ redirect(action:'workshop', controller:'production')
+ return
}
}