public CombatCleanup(ICombatable combatant1, ICombatable combatant2) { // Determine the losing sub: if (combatant1.GetDrillerCount() < combatant2.GetDrillerCount()) { loser = combatant1; winner = combatant2; } else if (combatant1.GetDrillerCount() > combatant2.GetDrillerCount()) { loser = combatant2; winner = combatant1; } else { // Tie. Compare specialist count. if (combatant1.GetSpecialistManager().GetSpecialistCount() < combatant2.GetSpecialistManager().GetSpecialistCount()) { loser = combatant1; winner = combatant2; } else if (combatant2.GetSpecialistManager().GetSpecialistCount() > combatant2.GetSpecialistManager().GetSpecialistCount()) { loser = combatant2; winner = combatant1; } else if (combatant1 is Outpost || combatant2 is Outpost) { winner = combatant1 is Outpost ? combatant1 : combatant2; loser = combatant1 is Outpost ? combatant2 : combatant1; } else { // Complete tie. isTie = true; // winner & loser don't matter in a tie. winner = combatant1; loser = combatant2; } } initialLoserDrillerCount = loser.GetDrillerCount(); losingPlayer = loser.GetOwner(); loserSpecialists = loser.GetSpecialistManager().GetSpecialists(); }
/// <summary> /// Performs the reverse action of the driller combat to undo. /// </summary> /// <returns>if the event was reversed</returns> public bool BackwardAction() { if (_eventSuccess) { // Add any removed subs back. if (_combatant1 is Sub && (_combatant1.GetDrillerCount() < 0 || (_combatant1.GetDrillerCount() == 0 && _combatant1.GetSpecialistManager().GetSpecialistCount() == 0))) { Game.TimeMachine.GetState().AddSub((Sub)_combatant1); } if (_combatant2 is Sub && (_combatant2.GetDrillerCount() < 0 || (_combatant2.GetDrillerCount() == 0 && _combatant2.GetSpecialistManager().GetSpecialistCount() == 0))) { Game.TimeMachine.GetState().AddSub((Sub)_combatant2); } // Restore driller counts. _combatant1.SetDrillerCount(_preCombatDrillers1); _combatant2.SetDrillerCount(_preCombatDrillers2); } return(_eventSuccess); }
/// <summary> /// Performs driller combat between two subs /// </summary> /// <returns>If the event was succesfull</returns> public bool ForwardAction(TimeMachine timeMachine, GameState state) { if (Validator.ValidateICombatable(state, _combatant1) && Validator.ValidateICombatable(state, _combatant2)) { _preCombatDrillers1 = _combatant1.GetDrillerCount(); _preCombatDrillers2 = _combatant2.GetDrillerCount(); _combatant1.RemoveDrillers(_preCombatDrillers2); _combatant2.RemoveDrillers(_preCombatDrillers1); this._eventSuccess = true; } else { this._eventSuccess = false; } return(this._eventSuccess); }
public bool ForwardAction(TimeMachine timeMachine, GameState state) { if (isTie) { // TODO: Handle tie. return(false); } if (loser is Sub) { // Cleanup the sub. if (loser.GetSpecialistManager().GetSpecialistCount() > 0) { loser.GetSpecialistManager().captureAll(); ((Sub)loser).IsCaptured = true; } else { // Remove the sub state.RemoveSub((Sub)loser); } } if (loser is Outpost) { // Transfer Ownership and give drillers. loser.SetOwner(winner.GetOwner()); // Remove the winning sub and make it arrive at the outpost. loser.SetDrillerCount(0); loser.AddDrillers(winner.GetDrillerCount()); // Transfer any specialists to the outpost. loser.GetSpecialistManager().captureAll(); winner.GetSpecialistManager().transferSpecialistsTo(loser.GetSpecialistManager()); // Remove the incoming sub. state.RemoveSub((Sub)winner); } this.isSuccess = true; return(isSuccess); }
public void ForwardEffect(ICombatable friendly, ICombatable enemy) { enemy.RemoveDrillers((int)(enemy.GetDrillerCount() * _stealPercent)); }