Example #1
0
 public Map(int id, bool[,] filled, PositionedUnit unit, ImmutableStack<Unit> nextUnits, ImmutableHashSet<PositionedUnit> usedPositions, Scores scores, bool died = false)
 {
     Id = id;
     NextUnits = nextUnits;
     Width = filled.GetLength(0);
     Height = filled.GetLength(1);
     Filled = filled;
     Unit = IsValidPosition(unit) ? unit : PositionedUnit.Null;
     UsedPositions = usedPositions.Add(Unit);
     Scores = scores;
     Died = died;
 }
Example #2
0
 private Map(int id, bool[,] filled, PositionedUnit unit, ImmutableStack<Unit> nextUnits, Scores scores)
     : this(id, filled,
            unit,
            nextUnits, ImmutableHashSet<PositionedUnit>.Empty.Add(unit), scores)
 {
 }
Example #3
0
 public Map(int id, bool[,] filled, ImmutableStack<Unit> nextUnits, Scores scores)
     : this(id, filled,
            PositionNewUnit(filled.GetLength(0), nextUnits),
            nextUnits.TryPop(), scores)
 {
 }
Example #4
0
        public Map LockUnit()
        {
            if (IsOver) return this;
            var f = (bool[,])Filled.Clone();
            foreach (var cell in Unit.Members)
                f[cell.X, cell.Y] = true;

            var ls_old = Scores.ClearedLinesCountAtThisMap;
            var ls = RemoveFilledLines(f);
            var size = Unit.Members.Count();

            var points = size + 100 * (1 + ls) * ls / 2;
            var line_bonus = 0;
            if (ls_old > 1)
                line_bonus = (int)Math.Floor((ls_old - 1) * points / 10f);

            var newScores = new Scores(Scores.TotalScores + points + line_bonus, ls);

            return new Map(Id, f, NextUnits, newScores);
        }