Example #1
0
        public void CreateRegion(IBatchOperationHandle batchOperationHandleInterface, Guid sessionId, Guid regionId, Guid continentId, String name, IEnumerable <Guid> connectedRegions, UInt32 cardValue)
        {
            BatchOperationHandle batchOperationHandle = batchOperationHandleInterface as BatchOperationHandle;

            // Create a new table entry
            RegionTableEntry newRegion = new RegionTableEntry(sessionId, regionId, continentId, name, cardValue);

            newRegion.IsValid();
            newRegion.SetConnectedRegions(connectedRegions);
            batchOperationHandle.BatchOperation.Insert(newRegion);

            // Create a new card for this region
            CardTableEntry newCard = new CardTableEntry(sessionId, regionId);

            newCard.IsValid();
            newCard.ValueRaw = (Int32)cardValue;
            batchOperationHandle.BatchOperation.Insert(newCard);
        }
Example #2
0
        public void AssignRegionOwnership(IBatchOperationHandle batchOperationHandleInterface, IEnumerable <IRegionData> regions, Dictionary <Guid, OwnershipChange> ownershipChanges)
        {
            BatchOperationHandle batchOperationHandle = batchOperationHandleInterface as BatchOperationHandle;

            // Get NationTableEntry for every player that needs updating
            var updateOperations = from ownershipChange in ownershipChanges
                                   join region in regions.Cast <RegionTableEntry>() on ownershipChange.Key equals region.RegionId
                                   select new { Region = region, NewOwner = ownershipChange.Value.UserId, NewTroopCount = (Int32)ownershipChange.Value.TroopCount };

            // Modify entries as required
            foreach (var operation in updateOperations)
            {
                RegionTableEntry regionEntry = operation.Region;
                regionEntry.IsValid();
                regionEntry.OwnerId                      = operation.NewOwner;
                regionEntry.StoredTroopCount             = operation.NewTroopCount;
                regionEntry.StoredTroopsCommittedToPhase = 0;
                batchOperationHandle.BatchOperation.Replace(regionEntry);
            }
        }