/** A Wizard with a smattering of problems */ protected static CharacterWrapper _testScenario1(GameData data) { GameObject character = data.getGameObjectByName("Wizard"); GameObject f1 = data.getGameObjectByName("Test Fly Chit 1"); character.add(f1); System.out.println(character); CharacterWrapper wrapper = new CharacterWrapper(character); wrapper.setCharacterLevel(4); wrapper.initChits(); // artifically fatigue and wound some chits ArrayList list = new ArrayList(wrapper.getAllChits()); Collections.sort(list); int n = 0; for (Iterator i = list.iterator(); i.hasNext(); ) { CharacterActionChitComponent aChit = (CharacterActionChitComponent) i.next(); System.out.println((n++) + " " + aChit.getGameObject().getName()); } CharacterActionChitComponent aChit = (CharacterActionChitComponent) list.get(1); aChit.getGameObject().setThisAttribute("action", "FLY"); aChit.getGameObject().setThisAttribute("effort", "1"); // aChit.makeFatigued(); // for (int i=4;i<11;i++) { // aChit = (CharacterActionChitComponent)list.get(i); // aChit.makeWounded(); // } aChit = (CharacterActionChitComponent) list.get(11); aChit.enchant(); // (new Curse(new JFrame())).applyThree(wrapper); return wrapper; }
protected static CharacterWrapper _testScenario2(GameData data, boolean preFatigue) { GameObject character = data.getGameObjectByName("White Knight"); System.out.println(character); CharacterWrapper wrapper = new CharacterWrapper(character); wrapper.setCharacterLevel(4); wrapper.initChits(); // artifically fatigue and wound some chits ArrayList list = new ArrayList(wrapper.getAllChits()); Collections.sort(list); if (preFatigue) { CharacterActionChitComponent aChit = (CharacterActionChitComponent) list.get(3); aChit.makeFatigued(); aChit = (CharacterActionChitComponent) list.get(7); aChit.makeFatigued(); } // //for (int i=4;i<11;i++) { // aChit = (CharacterActionChitComponent)list.get(i); // aChit.makeWounded(); // } // for (int i=8;i<10;i++) { // CharacterActionChitComponent aChit = (CharacterActionChitComponent)list.get(i); // aChit.makeWounded(); // } // (new Curse(new JFrame())).applyThree(wrapper); return wrapper; }
protected void activeClick(CharacterActionChitComponent clickedChit) { if (needsToFatigue()) { if (clickedChit != null) { if (validChit(clickedChit)) { int effort = clickedChit.getEffortAsterisks(); if (clickedChit.isColor()) { effort = 1; // color chits only count as one! } // go ahead if ((currentCount - effort) >= -1) { // allowed to dip one into the hole if (effort == 0) { moveChit(clickedChit, activeChits, woundedChits); updateEffort(clickedChit, -1); } else { moveChit(clickedChit, activeChits, fatiguedChits); updateEffort(clickedChit, -effort); makeChangeType = TYPE_NA; if (currentCount < 0) { if (clickedChit.isMove()) { makeChangeType = TYPE_MOVE; } else if (clickedChit.isFight() || clickedChit.isFightAlert()) { makeChangeType = TYPE_FIGHT; } } } } } } } }
protected boolean canMakeChange() { for (Iterator i = fatiguedChits.getAllChits().iterator(); i.hasNext(); ) { CharacterActionChitComponent chit = (CharacterActionChitComponent) i.next(); int effort = chit.getEffortAsterisks(); if (effort == 1 && validChit(chit, true)) { // They CAN make change return true; } } return false; }
private boolean areColorChits() { for (Iterator i = activeChits.getAllChits().iterator(); i.hasNext(); ) { ChitComponent chit = (ChitComponent) i.next(); if (chit.isActionChit()) { CharacterActionChitComponent aChit = (CharacterActionChitComponent) chit; if (validChit(aChit) && aChit.isColor()) { return true; } } } return false; }
protected void updateEffort(CharacterActionChitComponent clickedChit, int count) { currentCount += count; if (clickedChit.isAnyEffort()) return; if (countsAsMove(clickedChit) && move != INFINITE) { move += count; if (move < 0 && !canMakeChange()) { lostAsterisks -= move; currentCount -= move; move = 0; } } else if (countsAsFight(clickedChit) && fight != INFINITE) { fight += count; if (fight < 0 && !canMakeChange()) { lostAsterisks -= fight; currentCount -= fight; fight = 0; } } else if (countsAsMagic(clickedChit) && magic != INFINITE) { magic += count; if (magic < 0 && !canMakeChange()) { lostAsterisks -= magic; currentCount -= magic; magic = 0; } } }
protected boolean validChit(CharacterActionChitComponent chit, boolean makingChange) { int effort = chit.getEffortAsterisks(); boolean validMove = validEffortAdjustment(move, effort, makingChange) && countsAsMove(chit) && (makeChangeType == TYPE_NA || makeChangeType == TYPE_MOVE); boolean validFight = validEffortAdjustment(fight, effort, makingChange) && countsAsFight(chit) && (makeChangeType == TYPE_NA || makeChangeType == TYPE_FIGHT); boolean validMagic = validEffortAdjustment(magic, effort, makingChange) && countsAsMagic(chit); return validMove || validFight || validMagic; }
protected boolean canClickFatigue(CharacterActionChitComponent clickedChit) { if (needsToMakeChange()) { // making change if (clickedChit != null) { if (validChit(clickedChit, true)) { int effort = clickedChit.getEffortAsterisks(); if (effort == 1) { return true; } } } } else if (needsToFatigue() && !areActiveEffortChits() && !areColorChits()) { return true; } return false; }
protected boolean canClickActive(CharacterActionChitComponent clickedChit) { if (needsToFatigue()) { if (clickedChit != null) { if (validChit(clickedChit)) { if (clickedChit.isColor()) { if (!areActiveEffortChits()) { return true; } } else { int effort = clickedChit.getEffortAsterisks(); if (effort > 0) { // go ahead if ((currentCount - effort) >= -1) { // allowed to dip one into the hole return true; } } else if (!areActiveEffortChits() && !areColorChits() && !areFatiguedChits()) { return true; } } } } } return false; }
protected void fatigueClick(CharacterActionChitComponent clickedChit) { if (needsToMakeChange()) { // making change if (clickedChit != null) { if (validChit(clickedChit, true)) { int effort = clickedChit.getEffortAsterisks(); if (effort == 1) { moveChit(clickedChit, fatiguedChits, activeChits); updateEffort(clickedChit, effort); } } } } else if (needsToFatigue()) { // wounding fatigue chits if (clickedChit != null) { if (validChit(clickedChit)) { moveChit(clickedChit, fatiguedChits, woundedChits); updateEffort(clickedChit, -1); } } } }
protected boolean countsAsMagic(CharacterActionChitComponent chit) { return chit.isColor() || chit.isMagic() || chit.isAnyEffort(); }
protected boolean countsAsFight(CharacterActionChitComponent chit) { return chit.isFight() || chit.isFightAlert() || chit.isAnyEffort(); }
protected boolean countsAsMove(CharacterActionChitComponent chit) { return chit.isMove() || chit.isFly() || chit.isAnyEffort(); }