Ejemplo n.º 1
0
        /// <Summary>
        /// Update the movement of a stack.
        /// </Summary>
        /// <param name="battleStep">Movement to display.</param>
        private void DoBattleStepMovement(BattleStepMovement battleStep)
        {
            Stack stack = null;

            theBattle.Stacks.TryGetValue(battleStep.StackKey, out stack);

            if (stack != null)
            {
                UpdateStackDetails(stack);
                stack.Position = battleStep.Position; // move the icon
            }
            else
            {
                ClearStackDetails();
            }

            movedFrom.Text = stack.Position.ToString();
            movedTo.Text   = battleStep.Position.ToString();
            stack.Position = battleStep.Position;

            // We have moved, clear out the other fields as they are not relevant to this step.
            ClearTargetDetails();
            ClearWeapons();

            battlePanel.Invalidate();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Move stacks towards their targets (if any). Record each movement in the
        /// battle report.
        /// </summary>
        /// <param name="battlingStacks">All stacks in the battle.</param>
        public void MoveStacks(List <Stack> battlingStacks)
        {
            // Movement in Squares per Round
            //                  Round
            // Movement  1  2  3  4  5  6  7  8
            // 1/2       1  0  1  0  1  0  1  0
            // 3/4       1  1  0  1  1  1  0  1
            // 1         1  1  1  1  1  1  1  1
            // 1 1/4     2  1  1  1  2  1  1  1
            // 1 1/2     2  1  2  1  2  1  2  1
            // 1 3/4     2  2  1  2  2  2  1  2
            // 2         2  2  2  2  2  2  2  2
            // 2 1/4     3  2  2  2  3  2  2  2
            // 2 1/2     3  2  3  2  3  2  3  2
            // repeats for rounds 9 - 16

            // In Stars! each round breaks movement into 3 phases.
            // Phase 1: All stacks that can move 3 squares this round get to move 1 square.
            // Phase 2: All stacks that can move 2 or more squares this round get to move 1 square.
            // Phase 3: All stacks that can move this round get to move 1 square.
            // TODO (priority 3) - verify that a ship should be able to move 1 square per phase if it has 3 move points, or is it limited to 1 per turn?
            for (var phase = 1; phase <= movementPhasesPerRound; phase++)
            {
                // TODO (priority 5) - Move in order of ship mass, juggle by 15%
                foreach (Stack stack in battlingStacks)
                {
                    if (stack.Target != null & !stack.IsStarbase)
                    {
                        NovaPoint from = stack.Position;
                        NovaPoint to   = stack.Target.Position;

                        int movesThisRound = 1; // FIXME (priority 6) - kludge until I implement the above table
                        if (stack.BattleSpeed <= 0.5)
                        {
                            movesThisRound = movementTable[0, battleRound % 8];
                        }
                        else if (stack.BattleSpeed <= 0.75)
                        {
                            movesThisRound = movementTable[1, battleRound % 8];
                        }
                        else if (stack.BattleSpeed <= 1.0)
                        {
                            movesThisRound = movementTable[2, battleRound % 8];
                        }
                        else if (stack.BattleSpeed <= 1.25)
                        {
                            movesThisRound = movementTable[3, battleRound % 8];
                        }
                        else if (stack.BattleSpeed <= 1.5)
                        {
                            movesThisRound = movementTable[4, battleRound % 8];
                        }
                        else if (stack.BattleSpeed <= 1.75)
                        {
                            movesThisRound = movementTable[5, battleRound % 8];
                        }
                        else if (stack.BattleSpeed <= 2.0)
                        {
                            movesThisRound = movementTable[6, battleRound % 8];
                        }
                        else if (stack.BattleSpeed <= 2.25)
                        {
                            movesThisRound = movementTable[7, battleRound % 8];
                        }
                        else
                        {
                            // stack.BattleSpeed > 2.25
                            movesThisRound = movementTable[8, battleRound % 8];
                        }

                        bool moveThisPhase = true;
                        switch (phase)
                        {
                        case 1:
                        {
                            moveThisPhase = movesThisRound == 3;
                            break;
                        }

                        case 2:
                        {
                            moveThisPhase = movesThisRound >= 2;
                            break;
                        }

                        case 3:
                        {
                            moveThisPhase = movesThisRound >= 1;
                            break;
                        }
                        }

                        // stack can move only after accumulating at least 1 move point, and after doing so expends that 1 move point
                        if (moveThisPhase)
                        {
                            stack.Position = PointUtilities.BattleMoveTo(from, to);

                            // Update the battle report with these movements.
                            BattleStepMovement report = new BattleStepMovement();
                            report.StackKey = stack.Key;
                            report.Position = stack.Position;
                            battle.Steps.Add(report);
                        }
                    }
                    // TODO (priority 7) - shouldn't stacks without targets flee the battle if their strategy says to do so? they're sitting ducks now!
                }
            }
        }