Exemple #1
0
        /// <summary>
        /// All Defenses are gone. Remove the stack from the battle (which
        /// exists only during the battle) and, more importantly, remove the
        /// token from its "real" fleet. Also, generate a "destroy" event to
        /// update the battle visualization display.
        /// </summary>
        /// <param name="target"></param>
        private void DestroyStack(Stack attacker, Stack target)
        {
            // report the losses
            battle.Losses[target.Owner] = battle.Losses[target.Owner] + target.Token.Quantity;

            // for the battle viewer / report
            BattleStepDestroy destroy = new BattleStepDestroy();

            destroy.StackKey = target.Key;
            battle.Steps.Add(destroy);

            // remove the Token from the Fleet, if it exists
            if (serverState.AllEmpires[target.Owner].OwnedFleets.ContainsKey(target.ParentKey))
            {
                serverState.AllEmpires[target.Owner].OwnedFleets[target.ParentKey].Composition.Remove(target.Token.Key); // remove the token from the fleet

                // remove the fleet if no more tokens
                if (serverState.AllEmpires[target.Owner].OwnedFleets[target.ParentKey].Composition.Count == 0)
                {
                    serverState.AllEmpires[target.Owner].OwnedFleets.Remove(target.ParentKey);
                    serverState.AllEmpires[target.Owner].FleetReports.Remove(target.ParentKey);
                    serverState.AllEmpires[attacker.Owner].FleetReports.Remove(target.ParentKey);  // added in Rev# 872
                }
            }

            // remove the token from the Stack (do this last so target.Token remains valid above)
            target.Composition.Remove(target.Key);
        }
Exemple #2
0
        /// <Summary>
        /// Deal with a ship being destroyed. Remove it from the containing stack and,
        /// if the token count drops to zero, destroy the whole stack.
        /// </Summary>
        /// <param name="destroy"></param>
        private void UpdateDestroy(BattleStepDestroy destroy)
        {
            damage.Text = "Ship destroyed";

            // Stacks have 1 token, so remove the stack at once.
            // Not sure they do - see ShipToken.Quantity - Dan 17 Apr 17

            myStacks.Remove(destroy.StackKey);
            battlePanel.Invalidate();
        }