private void applyItem(Character actingCharacter, Character target) { /* This is an absolute horrible way to do inventory. There will be an if statement for each type of consumable. * Actually design a good inventory system if there's time. R.F. 3/14/2014 */ if (usedItem.WhichItem == ItemEnum.HEALTHPOTION) {/* start if */ target.restoreHealth((int)((usedItem.BaseDamage/ 100.0) * target.MaximumHealth)); }/* end if */ if (usedItem.WhichItem == ItemEnum.MANAPOTION) {/* start if */ target.restoreMana((int)((usedItem.BaseDamage/100.0) * target.MaximumMana)); }/* end if */ if(usedItem.WhichItem == ItemEnum.BOMB ) {/* start if */ target.takeDamage(usedItem.BaseDamage); }/* end if */ battleEvents.Add(new BattleEvent(actingCharacter, this, target)); }
public Party( Character[] party ) { /* start constructor */ mParty = party; mPartySize = party.Length; mInventory = new List<Item>(); }
public BattleEvent(Character user, BattleAction action, Character target, int damage) { /* start constructor */ mUser = user; mAction = action; mTarget = target; mDamage = damage; }
private void spreadItem(Character actingCharacter, Character[] combatants) { for (int i = 0; i < combatants.Length; i++) { if (combatants[i].isPlayer && !usedItem.AffectEnemy || !combatants[i].isPlayer && usedItem.AffectEnemy) { applyItem(actingCharacter, combatants[i]); } } }
public void specificAction(Character actingCharacter, Character[] combatants) { if (!usedItem.isSingleTarget) { spreadItem(actingCharacter, combatants); } else { singleTargetItem(actingCharacter, specificTarget); } }
private void applyAbility(Character actingCharacter, Character target, int base_stat) { if (usedAbility.HEALING) { target.restoreHealth(usedAbility.BaseDamage * base_stat); } else { target.takeDamage(usedAbility.BaseDamage * base_stat); } battleEvents.Add(new BattleEvent(actingCharacter, this, target)); }
private void singleTargetAbility(Character actingCharacter, Character target) { int base_stat = 1; if (usedAbility.isMagic) { base_stat = actingCharacter.getStat(StatEnum.MAGIC); } else { base_stat = actingCharacter.getStat(StatEnum.STRENGTH); } applyAbility(actingCharacter, target, base_stat); }
public void specificAction(Character actingCharacter, Character[] combatants) { int cost = usedAbility.Cost; actingCharacter.useMana(cost); if (usedAbility.isSingleTarget) { spreadAbility(actingCharacter, combatants); } else { singleTargetAbility(actingCharacter, specificTarget); } }
private void applyAbility(Character actingCharacter, Character target, int base_stat) { damage = usedAbility.BaseDamage * base_stat; if (!usedAbility.AffectEnemy) { target.restoreHealth(damage); } else { target.takeDamage(damage); } battleEvents.Add(new BattleEvent(actingCharacter, this, target)); }
public void specificAction(Character actingCharacter, Character[] combatants) { int attack = actingCharacter.getStat(StatEnum.STRENGTH) + actingCharacter.WeaponDamage; int damage = attack - target.getStat(StatEnum.ARMOR); if (damage > 0) { target.takeDamage(damage); attackResult = " attacked and did " + damage + " to "; } else { attackResult = " was unable to damage "; } battleEvents.Add(new BattleEvent(actingCharacter, this, target)); }
private void applyItem(Character actingCharacter, Character target) { if (usedItem.IsMana) { target.restoreHealth((100 / usedItem.BaseDamage) * target.MaximumHealth); } else if (usedItem.IsHealthPotion) { target.restoreMana((100 / usedItem.BaseDamage) * target.MaximumHealth); } else /*This assumes that the default/only other consumable item is a bomb. v___v*/ { target.takeDamage((100 / usedItem.BaseDamage) * target.MaximumHealth); } battleEvents.Add(new BattleEvent(actingCharacter, this, target)); }
public BattleEvent(Character currentActor, BattleAction actorAction, Character actorTarget) { mActor = currentActor; mAction = actorAction; actionOutcome = mAction.toString(); mActee = actorTarget; if (mActee.isDead && !mActee.isPlayer) { ((PlayerCharacter)mActor).gainExperience(((Enemy)mActee).Worth); kill_string = ", " + mActee.Name + " was vanquished!"; } if (mActee.isDead && mActee.isPlayer) { kill_string = ", " + mActee.Name + " has been slain!"; } }
private Character[] getAliveCharacters(Party goodGuys) { /* start getAliveCharacters */ int i, j, count = 0; Character[] alivePlayers; for (i = 0; i < goodGuys.Size; i++) if (!goodGuys.getCharacter(i).isDead) count++; alivePlayers = new Character[count]; for( i = 0,j = 0; i < goodGuys.Size; i++ ) if (!goodGuys.getCharacter(i).isDead) {/* start if */ alivePlayers[j] = goodGuys.getCharacter(i); j++; }/* end if */ return alivePlayers; }
private void singleTargetItem(Character actingCharacter, Character target) { applyItem(actingCharacter, target); }
private AbilityAction HandleAbilitySelection(Character character, Party badGuys) { /* start HandleAbilitySelection */ Character target; Ability ability; int i = 0; Console.WriteLine("Which ability would you like to use?"); foreach (Ability candidate in character.Abilities) {/* start loop */ Console.WriteLine(i + ". " + candidate.Name + "-Mana Cost: " + candidate.Cost); i++; }/* end loop */ ability = character.Abilities.getAbilityAtIndex(sanitizeInput(0,character.Abilities.Count - 1)); if (ability.AffectEnemy) target = getTarget(badGuys, BADGUYS); else target = getTarget(mGoodGuys, GOODGUYS); return new AbilityAction(ability, target); }
private ItemAction HandleItemSelection(Character character, Party badGuys) { /* start HandleItemSelection */ Console.WriteLine("Which item would you like to use?"); Ability[] items = mGoodGuys.Consumables; Ability choice; int i; if (items != null) {/* start if */ for (i = 0; i < items.Length; i++) Console.WriteLine(i + ". " + items[i].Name); choice = items[sanitizeInput(0,items.Length - 1)]; mGoodGuys.removeItem(choice); if (choice.AffectEnemy) return new ItemAction(choice); else return new ItemAction(choice, getTarget(mGoodGuys, GOODGUYS)); }/* end if */ Console.WriteLine( "You have no items!" ); return null; }
public ItemAction(Ability itemToUse, Character targetedCharacter) { usedItem = itemToUse; specificTarget = targetedCharacter; }
private void spreadAbility(Character actingCharacter, Character[] combatants) { int base_stat = 1; if (usedAbility.isMagic) { base_stat = actingCharacter.getStat(StatEnum.MAGIC); } else { base_stat = actingCharacter.getStat(StatEnum.STRENGTH); } for (int i = 0; i < combatants.Length; i++) { if (combatants[i].isPlayer && !usedAbility.AffectEnemy || !combatants[i].isPlayer && usedAbility.AffectEnemy) { applyAbility(actingCharacter, combatants[i], base_stat); } } }
private void spreadAbility(Character actingCharacter, Character[] combatants) { int base_stat = 1; if (usedAbility.isMagic) { base_stat = actingCharacter.getStat(StatEnum.MAGIC); } else { base_stat = actingCharacter.getStat(StatEnum.STRENGTH); } /* This loop does not take into account that enemies can have abilities as well. Maybe I didn't communicate that */ for (int i = 0; i < combatants.Length; i++) { if (actingCharacter.isPlayer) { if ((combatants[i].isPlayer && !usedAbility.AffectEnemy) || (!combatants[i].isPlayer && usedAbility.AffectEnemy)) applyAbility(actingCharacter, combatants[i], base_stat); } else { if ((!combatants[i].isPlayer && !usedAbility.AffectEnemy) || (combatants[i].isPlayer && usedAbility.AffectEnemy)) applyAbility(actingCharacter, combatants[i], base_stat); } } }
public BattleEvent(Character currentActor, BattleAction actorAction, Character actorTarget) { mActor = currentActor; actionOutcome = mAction.ToString(); mActee = actorTarget; }
public AbilityAction(Ability abilityToUse, Character targetedCharacter) { usedAbility = abilityToUse; specificTarget = targetedCharacter; }
private BattleAction CreateBattleAction(ActionEnum action,Character character, Party badGuys ) { /* start CreateBattleAction */ if (action == ActionEnum.ATTACK) return new AttackAction(getTarget(badGuys, BADGUYS)); if (action == ActionEnum.ABILITY) return HandleAbilitySelection(character, badGuys); if (action == ActionEnum.ITEM) return HandleItemSelection(character, badGuys); return null; }
public void equipItem( Item item, Character target ) { /* start equipItem */ mInventory.Remove( item ); if (item.Type == ItemType.WEAPON) {/* start if */ mInventory.Add(target.Weapon); target.Weapon = (Weapon)item; }/* end if */ }
public AttackAction(Character targetedCharacter) { target = targetedCharacter; }
public bool CompareTo(Character character) { /* start CompareTo */ return this.getStat(StatEnum.AGILITY) < character.getStat(StatEnum.AGILITY); }
private void selectNextCharacter() { int i = (currentActorIndex + 1) % turnOrder.Length; currentActor = turnOrder[i]; while (!currentActor.isDead) { i = (i + 1) % turnOrder.Length; currentActor = turnOrder[i]; currentActorIndex = i; } }
public Character[] getTurnOrder(Party otherParty) { /* start getTurnOrder */ int size = this.mPartySize + otherParty.mPartySize; int i, j; Character[] turnOrder = new Character[size]; Character temp; for (i = 0; i < mParty.Length; i++) turnOrder[ i ] = mParty[ i ]; for( j = 0; j < otherParty.mPartySize; j++, i++ ) turnOrder[ i ] = otherParty.mParty[ j ]; for (i = 0; i < size; i++) for (j = 0; j < size; j++) if ( turnOrder[ i ].CompareTo( turnOrder[ j ] ) ) {/* start if */ temp = turnOrder[i]; turnOrder[i] = turnOrder[j]; turnOrder[j] = temp; }/* end if */ return turnOrder; }
private void initialize() { /* start initialize */ ClassEnum choice; int i; String name; Character[] characters = new Character[ Party.MAXPARTY ]; mView = new TextView(); for (i = 0; i < Party.MAXPARTY; i++) {/* start loop */ choice = mView.getClassChoice(); name = mView.getCharacterName(); characters[ i ] = CharacterFactory.getInstance().getCharacter(choice, name); }/* end loop */ mGoodGuys = new Party(characters); mView.GoodGuys = mGoodGuys; mBattle = new Battle(this, mGoodGuys); mDungeon = Dungeon.getInstance(this, mView); mView.Dungeon = mDungeon.GetGrid(); }
private void initialize() { /* start initialize */ int choice, i; String[] classes = new String[ 6 ] { "Warrior", "Theif", "Monk", "White Mage", "Black Mage", "Red Mage" }; String name; Character[] characters = new Character[ Party.MAXPARTY ]; for (i = 0; i < Party.MAXPARTY; i++) {/* start loop */ mView.sendOutput("What class type do you want? You get 3."); mView.sendOutput(classes.GetEnumerator(), TypeEnum.STRING); choice = (int)mView.getInput(TypeEnum.INT); name = (string)mView.getInput(TypeEnum.STRING); characters[ i ] = CharacterCreationFactory(choice, name); }/* end loop */ mGoodGuys = new Party(characters); mBattle = new BattleSystem(this, mGoodGuys); mDungeon = new Dungeon(this, mGoodGuys); }
public BattleAction getPlayerAction( Character character, Party badGuys ) { /* start getPlayerAction */ return mView.getPlayerAction(character, badGuys); }