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); }
/// <summary> /// Performs the reverse action of the driller combat to undo. /// </summary> /// <returns>if the event was reversed</returns> public bool BackwardAction(TimeMachine timeMachine, GameState state) { if (_eventSuccess) { // Restore driller counts. _combatant1.SetDrillerCount(_preCombatDrillers1); _combatant2.SetDrillerCount(_preCombatDrillers2); } return(_eventSuccess); }
/// <summary> /// Performs the reverse action of the driller combat to undo. /// </summary> /// <returns>if the event was reversed</returns> public bool BackwardAction() { if (_eventSuccess) { // Restore driller counts. _combatant1.SetDrillerCount(_preCombatDrillers1); _combatant2.SetDrillerCount(_preCombatDrillers2); } return(_eventSuccess); }
/// <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); }