Exemple #1
0
        public bool TakeSlot(bool isX, int row, int col)
        {
            var player = isX ? "X" : "O";
            var slot   = Slots.Find(s => s.Row == row && s.Column == col);

            // ตรวจสอบเกมยังไม่จบและช่องนี้ว่าง
            if (GameState == State.Playing && slot.IsX == null)
            {
                // ตาแรก
                if (ThisTurn == string.Empty)
                {
                    ThisTurn = player;
                }

                // เป็นตาของผู้เล่นหรือไม่
                if (ThisTurn == player)
                {
                    slot.IsX = player == "X";
                    ChangeTurn();

                    return(true);
                }

                return(false);
            }

            return(false);
        }
Exemple #2
0
        public virtual void Add(TItem item)
        {
            Ensure.That(item, nameof(item)).IsNotNull();
            Ensure.That(
                AllowedFor(item) &&
                item.AllowedFor(this) &&
                Slots.Find(item.Slot).Exists(s => s.AllowedFor(item)),
                nameof(item),
                opt => opt.WithMessage($"'{item}' is not allowed in this container: '{this}'."))
            .IsTrue();

            DoAdd(item);

            _items.OnNext(Items.Add(item.Slot, item));

            this.LogDebug("Item '{}' is added to the container.", item);

            _onAdd.OnNext(item);
        }
Exemple #3
0
 public BaseSlot this[WeaponType type] => Slots.Find(slot => Match(slot, type));
Exemple #4
0
 public BaseSlot this[ArmorType type] => Slots.Find(slot => Match(slot, type));