private ArrayList<SpellWrapper> getSpells(String duration) { GameData data = getGameObject().getGameData(); ArrayList ids = new ArrayList(); if (duration == null) { ids.addAll(getList(PERMANENT_SPELLS)); ids.addAll(getList(DAY_SPELLS)); ids.addAll(getList(COMBAT_SPELLS)); ids.addAll(getList(PHASE_SPELLS)); ids.addAll(getList(MOVE_SPELLS)); } else { ids.addAll(getList(duration)); } ArrayList<SpellWrapper> ret = new ArrayList<SpellWrapper>(); for (Iterator i = ids.iterator(); i.hasNext(); ) { String id = (String) i.next(); GameObject go = data.getGameObject(Long.valueOf(id)); ret.add(new SpellWrapper(go)); } return ret; }
public static SpellMasterWrapper getSpellMaster(GameData data) { // System.out.println("MASTER_ID = "+MASTER_ID+", dataid = "+data.dataid); if (MASTER_ID == null) { // System.out.println(data.toIdentifier()+": MASTER_ID is null"); GamePool pool = new GamePool(data.getGameObjects()); ArrayList list = pool.find(SPELL_MASTER_KEY); GameObject gm = null; if (list != null && list.size() == 1) { gm = (GameObject) list.iterator().next(); // System.out.println(data.toIdentifier()+": Found a SpellMaster!"); } if (gm == null) { gm = data.createNewObject(); gm.setName(SPELL_MASTER_KEY); gm.setThisAttribute(SPELL_MASTER_KEY); // System.out.println(data.toIdentifier()+": Creating a new SpellMaster!"); } MASTER_ID = new Long(gm.getId()); return new SpellMasterWrapper(gm); } else { return new SpellMasterWrapper(data.getGameObject(MASTER_ID)); } }