コード例 #1
0
        public void CommitTroopsToPhase(IBatchOperationHandle batchOperationHandleInterface, IRegionData sourceRegion, UInt32 troopsToCommit)
        {
            DummyBatchOperationHandle batchOperationHandle = batchOperationHandleInterface as DummyBatchOperationHandle;
            DummyRegionData           region = sourceRegion as DummyRegionData;

            if (region != null && region.TroopCount > region.TroopsCommittedToPhase + troopsToCommit)
            {
                batchOperationHandle.QueuedOperations.Add(() =>
                {
                    region.TroopsCommittedToPhase += troopsToCommit;
                });
            }
            else
            {
                throw new InvalidOperationException("Invalid arguments passed");
            }
        }
コード例 #2
0
        public void CreateRegion(IBatchOperationHandle batchOperationHandleInterface, Guid sessionId, Guid regionId, Guid continentId, String name, IEnumerable <Guid> connectedRegions, UInt32 cardValue)
        {
            DummyBatchOperationHandle batchOperationHandle = batchOperationHandleInterface as DummyBatchOperationHandle;

            batchOperationHandle.QueuedOperations.Add(() =>
            {
                RegionData[regionId] = new DummyRegionData(sessionId, regionId, continentId, String.Empty, cardValue);
                foreach (Guid connectedRegion in connectedRegions)
                {
                    RegionData[regionId].ConnectedRegionIds.Add(connectedRegion);
                }
            });
            batchOperationHandle.QueuedOperations.Add(() =>
            {
                CardData[regionId] = new DummyCardData(regionId, cardValue);
            });
        }
コード例 #3
0
        public void AssignRegionOwnership(IBatchOperationHandle batchOperationHandleInterface, IEnumerable <IRegionData> regions, Dictionary <Guid, OwnershipChange> ownershipChanges)
        {
            DummyBatchOperationHandle batchOperationHandle = batchOperationHandleInterface as DummyBatchOperationHandle;

            foreach (var change in ownershipChanges)
            {
                if (RegionData.ContainsKey(change.Key))
                {
                    DummyRegionData regionData = RegionData[change.Key];
                    batchOperationHandle.QueuedOperations.Add(() =>
                    {
                        regionData.OwnerId                = change.Value.UserId;
                        regionData.TroopCount             = change.Value.TroopCount;
                        regionData.TroopsCommittedToPhase = 0;
                        regionData.GenerateNewEtag();
                    });
                }
                else
                {
                    throw new InvalidOperationException("Invalid region id specified");
                }
            }
        }
コード例 #4
0
 public DummyRegionData SetupRegion(Guid sessionId, Guid regionId, Guid continentId, String initialOwner, UInt32 cardValue)
 {
     RegionData[regionId] = new DummyRegionData(sessionId, regionId, continentId, initialOwner, cardValue);
     CardData[regionId]   = new DummyCardData(regionId, cardValue);
     return(RegionData[regionId]);
 }
コード例 #5
0
ファイル: DummyRegionData.cs プロジェクト: StephenE/DevoLAN
 public DummyRegionData SetupRegionConnection(DummyRegionData otherRegion)
 {
     ConnectedRegionIds.Add(otherRegion.RegionId);
     otherRegion.ConnectedRegionIds.Add(RegionId);
     return(this);
 }