Beispiel #1
0
 public Maybe <DungeonCell> LayTile(LetterTile letterTile)
 {
     if (LetterTile.HasValue)
     {
         return(Maybe.None <DungeonCell>());
     }
     return(new DungeonCell(Position, Occupant, letterTile));
 }
Beispiel #2
0
        internal Maybe <GameState> WordEntryLetter(char letter)
        {
            if (!TilePlacer.HasValue)
            {
                return(Maybe.None <GameState>());
            }

            var tp = TilePlacer.Value;

            var pos       = tp.LevelPosition;
            var maybeCell = Dungeon.GetCell(pos);

            if (!maybeCell.HasValue)
            {
                return(Maybe.None <GameState>());
            }
            var cell = maybeCell.Value;

            if (cell.Occupant.HasValue)
            {
                return(Maybe.None <GameState>());
            }

            if (cell.LetterTile.HasValue)
            {
                //if (cell.LetterTile.Value.Value != letter)
                //    return Maybe.None<GameState>();

                tp = tp.AdvanceWord(Maybe.None <LetterTile>());
                return(new GameState(
                           Dungeon,
                           Player,
                           tp));
            }

            var player = Player.RemoveLetter(letter);

            if (!player.HasValue)
            {
                return(Maybe.None <GameState>());
            }

            var lt = new LetterTile(letter);

            var dg = Dungeon.PlaceLetterTile(tp.LevelPosition, lt);

            if (!dg.HasValue)
            {
                return(Maybe.None <GameState>());
            }

            tp = tp.AdvanceWord(lt);

            return(new GameState(
                       dg.Value,
                       player.Value,
                       tp));
        }
Beispiel #3
0
        public Maybe <Dungeon> PlaceLetterTile(Point levelPosition, LetterTile letterTile)
        {
            var level = ActiveLevel.LayTile(levelPosition, letterTile);

            if (!level.HasValue)
            {
                return(Maybe.None <Dungeon>());
            }
            return(new Dungeon(
                       level.Value,
                       levels
                       ));
        }
Beispiel #4
0
        internal Maybe <DungeonLevel> LayTile(Point levelPosition, LetterTile letterTile)
        {
            var cell = GetCell(levelPosition);

            if (!cell.HasValue)
            {
                return(Maybe.None <DungeonLevel>());
            }
            var newCell = cell.Value.LayTile(letterTile);

            if (!newCell.HasValue)
            {
                return(Maybe.None <DungeonLevel>());
            }
            return(new DungeonLevel(
                       Level,
                       cells.ToDictionary(
                           k => k.Key,
                           v => v.Value == cell.Value ? newCell.Value : v.Value
                           )
                       ));
        }