示例#1
0
文件: Unit.cs 项目: gmoller/Phoenix
        internal void DoPatrolAction()
        {
            var stackRecord  = _gameDataRepository.GetStackById(_unitRecord.StackId.Value);
            var updatedStack = new StackRecord(stackRecord, new Status(UnitStatus.Patrol));

            _gameDataRepository.Update(updatedStack);

            _unitRecord = new UnitRecord(_unitRecord, new MovementPoints(0.0f));
            _gameDataRepository.Update(_unitRecord);
            //SetSeenCells(stackRecord.LocationHex.Value);
        }
示例#2
0
文件: Stack.cs 项目: gmoller/Phoenix
        public Stack(int stackId)
        {
            _gameConfigCache = CallContext <GameConfigCache> .GetData("GameConfigCache");

            _gameDataRepository = CallContext <GameDataRepository> .GetData("GameDataRepository");

            _stackRecord = _gameDataRepository.GetStackById(stackId);
            var unitRecords = _gameDataRepository.GetUnitsByStackId(stackId);

            Units = new Units();
            foreach (var unitRecord in unitRecords)
            {
                Units.Add(new Unit(unitRecord.Id));
            }

            _gameDataRepository.StackUpdated += StackUpdated;
        }
示例#3
0
        public void Stack_tests()
        {
            var stackRecord = new StackRecord(1, new PointI(12, 9));

            _repo.Add(stackRecord);
            var id = stackRecord.Id;

            stackRecord = _repo.GetStackById(id);
            var stacks = _repo.GetStacksByFactionId(1);

            Assert.AreEqual(id, stackRecord.Id);
            Assert.AreEqual(1, stackRecord.FactionId.Value);
            Assert.AreEqual(UnitStatus.None, stackRecord.Status.Value);
            Assert.AreEqual(false, stackRecord.HaveOrdersBeenGivenThisTurn.Value);
            Assert.AreEqual(3, stacks.Count);
            Assert.AreEqual(1, stacks[0].Id);
            Assert.AreEqual(2, stacks[1].Id);

            stacks = _repo.GetStacksByLocationHex(new PointI(12, 9));
            Assert.AreEqual(1, stacks.Count);
            Assert.AreEqual(3, stacks[0].Id);

            stacks = _repo.GetStacksByOrdersNotBeenGivenThisTurnAndFactionId(1);
            Assert.AreEqual(3, stacks.Count);
            Assert.AreEqual(1, stacks[0].Id);
            Assert.AreEqual(2, stacks[1].Id);
            Assert.AreEqual(3, stacks[2].Id);

            var updatedStack = new StackRecord(stackRecord, stackRecord.LocationHex, new Status(UnitStatus.Patrol), new HaveOrdersBeenGivenThisTurn(true));

            _repo.Update(updatedStack);
            stackRecord = _repo.GetStackById(id);
            Assert.AreEqual(1, stackRecord.FactionId.Value);
            Assert.AreEqual(new PointI(12, 9), stackRecord.LocationHex.Value);
            Assert.AreEqual(UnitStatus.Patrol, stackRecord.Status.Value);
            Assert.AreEqual(true, stackRecord.HaveOrdersBeenGivenThisTurn.Value);

            updatedStack = new StackRecord(stackRecord, new LocationHex(new PointI(10, 10)));
            _repo.Update(updatedStack);
            stackRecord = _repo.GetStackById(id);
            Assert.AreEqual(1, stackRecord.FactionId.Value);
            Assert.AreEqual(new PointI(10, 10), stackRecord.LocationHex.Value);
            Assert.AreEqual(UnitStatus.Patrol, stackRecord.Status.Value);
            Assert.AreEqual(true, stackRecord.HaveOrdersBeenGivenThisTurn.Value);

            updatedStack = new StackRecord(stackRecord, new Status(UnitStatus.Explore));
            _repo.Update(updatedStack);
            stackRecord = _repo.GetStackById(id);
            Assert.AreEqual(1, stackRecord.FactionId.Value);
            Assert.AreEqual(new PointI(10, 10), stackRecord.LocationHex.Value);
            Assert.AreEqual(UnitStatus.Explore, stackRecord.Status.Value);
            Assert.AreEqual(true, stackRecord.HaveOrdersBeenGivenThisTurn.Value);

            updatedStack = new StackRecord(stackRecord, new HaveOrdersBeenGivenThisTurn(false));
            _repo.Update(updatedStack);
            stackRecord = _repo.GetStackById(id);
            Assert.AreEqual(1, stackRecord.FactionId.Value);
            Assert.AreEqual(new PointI(10, 10), stackRecord.LocationHex.Value);
            Assert.AreEqual(UnitStatus.Explore, stackRecord.Status.Value);
            Assert.AreEqual(false, stackRecord.HaveOrdersBeenGivenThisTurn.Value);
        }