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"); } }
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); }); }
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"); } } }
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]); }
public DummyRegionData SetupRegionConnection(DummyRegionData otherRegion) { ConnectedRegionIds.Add(otherRegion.RegionId); otherRegion.ConnectedRegionIds.Add(RegionId); return(this); }