Exemplo n.º 1
0
        public static ICell ICellFromRank(Rank rank, Ownership owner)
        {
            ICell ans;

            switch (rank)
            {
            case Rank.Flag:
                ans = new Flag(owner);
                break;

            case Rank.Spy:
                ans = new Spy(owner);
                break;

            case Rank.Scout:
                ans = new Scout(owner);
                break;

            case Rank.Miner:
                ans = new Miner(owner);
                break;

            case Rank.Sergeant:
                ans = new Sergeant(owner);
                break;

            case Rank.Lieutenant:
                ans = new Lieutenant(owner);
                break;

            case Rank.Captain:
                ans = new Captain(owner);
                break;

            case Rank.Major:
                ans = new Major(owner);
                break;

            case Rank.Colonel:
                ans = new Colonel(owner);
                break;

            case Rank.General:
                ans = new General(owner);
                break;

            case Rank.Marshal:
                ans = new Marshal(owner);
                break;

            case Rank.Bomb:
                ans = new Bomb(owner);
                break;

            default:
                ans = new EmptyCell(Ownership.Board);
                break;
            }

            return(ans);
        }
Exemplo n.º 2
0
        public static ICell ICellFromString(string identifier)
        {
            var       tokens = identifier.Split(",".ToCharArray(), 2);
            Ownership owner;

            switch (tokens[1])
            {
            case "Board":
                owner = Ownership.Board;
                break;

            case "FirstPlayer":
                owner = Ownership.FirstPlayer;
                break;

            case "SecondPlayer":
                owner = Ownership.SecondPlayer;
                break;

            default:
                return(null);
            }

            ICell ans;

            switch (tokens[0])
            {
            case "Common.EmptyCell":
                ans = new EmptyCell();
                break;

            case "Common.Enemy":
                ans = new Enemy(owner);
                break;

            case "Common.WaterCell":
                ans = new WaterCell();
                break;

            case "Common.Flag":
                ans = new Flag(owner);
                break;

            case "Common.Spy":
                ans = new Spy(owner);
                break;

            case "Common.Scout":
                ans = new Scout(owner);
                break;

            case "Common.Miner":
                ans = new Miner(owner);
                break;

            case "Common.Sergeant":
                ans = new Sergeant(owner);
                break;

            case "Common.Lieutenant":
                ans = new Lieutenant(owner);
                break;

            case "Common.Captain":
                ans = new Captain(owner);
                break;

            case "Common.Major":
                ans = new Major(owner);
                break;

            case "Common.Colonel":
                ans = new Colonel(owner);
                break;

            case "Common.General":
                ans = new General(owner);
                break;

            case "Common.Marshal":
                ans = new Marshal(owner);
                break;

            case "Common.Bomb":
                ans = new Bomb(owner);
                break;

            default:
                throw new NotImplementedException("ICellFromString: " + identifier);
            }

            return(ans);
        }