Permalink
Browse files

Add orders and the default player character as fixture files.

  • Loading branch information...
1 parent cb8536f commit 6ab4f4dcaff1bc89e819250cfa9ab0a79438b762 @dewarim committed Mar 16, 2013
Showing with 40 additions and 45 deletions.
  1. +9 −0 fixtures/game/orders.groovy
  2. +22 −0 fixtures/game/playerCharacters.groovy
  3. +9 −45 grails-app/conf/BootStrap.groovy
@@ -0,0 +1,9 @@
+import de.dewarim.goblin.pc.GoblinOrder
+import de.dewarim.goblin.pc.PlayerCharacter
+import de.dewarim.goblin.social.ChatterBox
+
+fixture{
+ ebonOrder(GoblinOrder, name:'order.ebon', description:'order.ebon.description',
+ leader: PlayerCharacter.findByName('Gobli'))
+ chatterBox(ChatterBox, name:'chatterbox.default.name', goblinOrder:ebonOrder)
+}
@@ -0,0 +1,22 @@
+import de.dewarim.goblin.UserAccount
+import de.dewarim.goblin.item.Item
+import de.dewarim.goblin.item.ItemType
+import de.dewarim.goblin.pc.PlayerCharacter
+import de.dewarim.goblin.social.MailBox
+import de.dewarim.goblin.social.MailBoxType
+
+def user = UserAccount.findByUsername('anon')
+def count = 0
+def ore = ItemType.findByName('item.iron.ore')
+def iron = ItemType.findByName('item.iron.bar')
+
+fixture{
+
+ gob(PlayerCharacter, name:'Gobli', user:user, gold:100, xp:10)
+ MailBoxType.list().each{box ->
+ "box${count++}"(MailBox, owner:gob, boxType:box)
+ }
+ gobOre(Item, type: ore, amount: 10, owner: gob)
+ gobIron(Item, type: iron, amount: 10, owner: gob)
+
+}
@@ -53,31 +53,31 @@ class BootStrap {
fixtureLoader.load('system/configEntries')
fixtureLoader.load('system/licenses')
+ // Note: the order of fixture files is in some cases relevant
+ // as for example 'game/items' will generate objects used by 'game/playerCharacters'
fixtureLoader.load('game/equipmentSlotTypes')
fixtureLoader.load('game/scripts')
fixtureLoader.load('game/towns')
fixtureLoader.load('game/images')
-
- PlayerCharacter gob = initPlayer(UserAccount.findByUsername('anon'))
-
fixtureLoader.load('game/combatAttributeTypes')
fixtureLoader.load('game/reputationMessages')
fixtureLoader.load('game/factions')
-
- initOrders(gob)
-
fixtureLoader.load('game/configEntries')
// initializes: towns, guilds, dice, skillSets
fixtureLoader.load('game/academies')
- initHelp()
-
fixtureLoader.load('game/shops')
fixtureLoader.load('game/items')
fixtureLoader.load('game/productComponents')
fixtureLoader.load('game/mobs')
fixtureLoader.load('game/questTemplates')
+ fixtureLoader.load('game/playerCharacters')
+ fixtureLoader.load('game/orders')
- initItems(gob)
+ PlayerCharacter.list().each{pc ->
+ pc.initializePlayerCharacter()
+ }
+
+ initHelp()
initTicks()
}
@@ -98,42 +98,6 @@ class BootStrap {
tickService.initialize()
}
- PlayerCharacter initPlayer(user) {
- log.debug("initialize player character")
- PlayerCharacter gob = new PlayerCharacter(name: 'Gobli', user: user, gold: 100, xp: 10)
- gob.save()
- gob.initializePlayerCharacter()
-
- def boxes = MailBoxType.list()
- boxes.each {boxType ->
- MailBox mailBox = new MailBox(owner: gob, boxType: boxType)
- mailBox.save()
- }
-
- return gob
- }
-
-
- void initItems(PlayerCharacter littleGoblin) {
- def ore = ItemType.findByName('item.iron.ore')
- def iron = ItemType.findByName('item.iron.bar')
- def someOre = new Item(type: ore, amount: 10, owner: littleGoblin)
- def someBars = new Item(type: iron, amount: 10, owner: littleGoblin)
- someOre.save()
- someBars.save()
-
- }
-
- void initOrders(PlayerCharacter pc) {
- log.debug("initialize Orders")
-
- GoblinOrder order = new GoblinOrder(name: 'Order of the Ebon Hand', leader: pc, description: 'The legendary Order of the Ebon Hand')
- order.addToMembers(pc)
- order.save()
- pc.goblinOrder = order
-
- }
-
void initHelp() {
Help academyHelp = new Help(messageId: 'help.skillSets')
academyHelp.save()

0 comments on commit 6ab4f4d

Please sign in to comment.