public void StockColor_NonEmptyStock_ReturnFirstCardColor() { var publicState = new PublicState() { Stock = new[] { new StockItem(0, new Card(Rank.Ace, Color.Clubs)) } }; var result = publicState.StockColor; Assert.Equal(Color.Clubs, result); }
public bool ServerGather(IStaticWorldObject worldObject, ICharacter character) { //MOD PublicState publicState = GetPublicState(worldObject); var lootDroplist = publicState.ProtoCharacterMob.LootDroplist; var dropItemContext = new DropItemContext(character, worldObject); CreateItemResult dropItemResultFinal = new CreateItemResult(); var level = publicState.Level; for (int i = 0; i < level; i++) { CreateItemResult dropItemResult; var attemptRemains = 200; do { dropItemResult = lootDroplist.TryDropToCharacterOrGround(character, character.TilePosition, dropItemContext, out _); dropItemResultFinal.MergeWith(dropItemResult); } // ensure that at least something is spawned... // perhaps that's not a good idea, but we have an attempts limit while (dropItemResult.TotalCreatedCount == 0 && --attemptRemains > 0); } if (!dropItemResultFinal.IsEverythingCreated) { Logger.Warning("Not all loot items were provided by " + worldObject + " - there is not enough space in inventory and around the character"); } // probably the attempts limit exceeded and nothing is spawned // we don't consider this as an issue as the probability of this is too rare Logger.Info(worldObject + " was gathered", character); Server.World.DestroyObject(worldObject); NotificationSystem.ServerSendItemsNotification(character, dropItemResultFinal); character.ServerAddSkillExperience <SkillHunting>(SkillHunting.ExperienceForGather * level); return(true); }
public static (Action, int) Train(PublicState publicGameState, CardsSet[] playersCards, int playerId) { playersCards[publicGameState.DealerId] = new CardsSet(); var gameState = new GameState() { DealerId = publicGameState.DealerId, NextPlayerId = publicGameState.NextPlayerId, PlayersCards = playersCards, PlayersPoints = publicGameState.PlayersPoints, PlayersUsedCards = publicGameState.PlayersUsedCards, Stock = publicGameState.Stock, TrumpsHistory = publicGameState.TrumpsHistory }; var(action, playersPoints) = MinMax(gameState); if (!action.HasValue) { throw new Exception("Given game state is final."); } return(action.Value, playersPoints[playerId]); }
protected override void SetupPublicState(PublicState state) { base.SetupPublicState(state); state.ProtoItemVehicleRepairKit = this.ProtoItemVehicleRepairKit; }
protected override void SetupPublicState(PublicState state) { base.SetupPublicState(state); state.ProtoItemCrowbarTool = this.ProtoItemCrowbarTool; }
public void SetWaterAmount(double waterAmount, double waterCapacity, PublicState publicState) { waterAmount = MathHelper.Clamp(waterAmount, 0, waterCapacity); this.WaterAmount = waterAmount; publicState.WaterAmountPercent = (byte)(100 * waterAmount / waterCapacity); }
protected override void SetupPublicState(PublicState state) { base.SetupPublicState(state); state.ProtoItemExplosive = (IProtoItemExplosive)this.ItemExplosive.ProtoItem; }
protected override void SetupPublicState(PublicState state) { base.SetupPublicState(state); state.ProtoItemConstructionTool = this.ProtoItemConstructionTool; }
protected override ITextureResource ClientGetTextureResource(IStaticWorldObject gameObject, PublicState state) { return(this.DefaultTexture); }
public TelegramService() { PublicMessages = new PublicState(); PrivateMessages = new PrivateState(); }
public void StockColor_EmptyStock_ThrowError() { var publicState = new PublicState(); Assert.Throws <Exception>(() => publicState.StockColor); }