Пример #1
0
 private int[] GetTankSequenceIndexes(TankMovementLookup[] TankMovementOrders)
 {
     int[] tankSequenceIndexes = new int[Constants.TANK_COUNT];
     for (int t = 0; t < tankSequenceIndexes.Length; t++)
     {
         TankMovementLookup lookup = TankMovementOrders[t];
         tankSequenceIndexes[t] = lookup.PlayerNumber | (lookup.TankNumber << 1);
     }
     return(tankSequenceIndexes);
 }
Пример #2
0
        // The following edge case is so rare, it's not worth handling:
        // public bool AllowUnresolvedMovesToTakePlaceIfTheOnlyDependenciesAreOnTrailingEdges { get; set; }

        private static TankMovementLookup[] GetTankMovementLookupsBySequenceRule(TankActionSequenceRule sequenceRule)
        {
            TankMovementLookup[] tankMovementLookups;
            switch (sequenceRule)
            {
            case TankActionSequenceRule.InPlayerThenIdOrder:
                tankMovementLookups = new TankMovementLookup[]
                {
                    new TankMovementLookup {
                        PlayerNumber = 0, TankNumber = 0
                    },
                    new TankMovementLookup {
                        PlayerNumber = 0, TankNumber = 1
                    },
                    new TankMovementLookup {
                        PlayerNumber = 1, TankNumber = 0
                    },
                    new TankMovementLookup {
                        PlayerNumber = 1, TankNumber = 1
                    }
                };
                break;

            case TankActionSequenceRule.Player1FirstAndLastByIdOrder:
                tankMovementLookups = new TankMovementLookup[]
                {
                    new TankMovementLookup {
                        PlayerNumber = 0, TankNumber = 0
                    },
                    new TankMovementLookup {
                        PlayerNumber = 1, TankNumber = 0
                    },
                    new TankMovementLookup {
                        PlayerNumber = 1, TankNumber = 1
                    },
                    new TankMovementLookup {
                        PlayerNumber = 0, TankNumber = 1
                    }
                };
                break;

            case TankActionSequenceRule.InTankIdOrder:
                tankMovementLookups = new TankMovementLookup[Constants.TANK_COUNT];
                for (int t = 0; t < Constants.TANK_COUNT; t++)
                {
                    Tank tank   = (Tank)Game.Current.Elements[t];
                    int  tankId = tank.Id;

                    /* Simulate the test harness issue that plagued a number of contestants...
                     * if (tankId == 0)
                     * {
                     *  tankId = 513;
                     * }
                     */
                    tankMovementLookups[tankId]
                        = new TankMovementLookup {
                        PlayerNumber = tank.PlayerNumber, TankNumber = tank.Number
                        };
                }
                break;

            default:
                tankMovementLookups = new TankMovementLookup[] { };
                break;
            }
            return(tankMovementLookups);
        }