public static AnimalItem GetAnimalItem(FarmAnimal farmAnimal) { List <Item> itemsToReturn = new List <Item>(); Animal?foundAnimal = AnimalExtension.GetAnimalFromType(farmAnimal.type.Value); return(DataLoader.AnimalData.getAnimalItem((Animal)foundAnimal)); }
private static string GetPlayerAct(AnimalContestItem animalContestInfo, FarmAnimal farmAnimal, List <AnimalContestItem> history) { StringBuilder playerAct = new StringBuilder(); if (animalContestInfo.FarmAnimalScore is AnimalContestScore score) { string animalName = farmAnimal.displayName; if (AnimalExtension.GetAnimalFromType(farmAnimal.type.Value) == Animal.Dinosaur && !history.Exists(h => h.PlayerAnimal == farmAnimal.type.Value)) { playerAct.Append($"/speak Lewis \"{i18n.Get("AnimalContest.Dialog.PlayerAct.Lewis.Dinosaur")}\""); playerAct.Append($"/question null \"{i18n.Get("AnimalContest.Dialog.PlayerAct.Player.DinosaurAnswers")}\""); playerAct.Append($"/splitSpeak Lewis \"{i18n.Get("AnimalContest.Dialog.PlayerAct.Lewis.DinosaurAnswers")}\""); } playerAct.Append($"/speak Lewis \"{i18n.Get("AnimalContest.Dialog.PlayerAct.Lewis.Begin", new { animalName })}\""); if (score.AgePoints == 0) { playerAct.Append($"/speak Lewis \"{i18n.Get("AnimalContest.Dialog.PlayerAct.Lewis.DisqualifyAge", new { animalName })}\""); } else if (score.TreatVariatyPoints == 0) { playerAct.Append($"/speak Lewis \"{i18n.Get("AnimalContest.Dialog.PlayerAct.Lewis.DisqualifyTreatVariaty", new { animalName })}\""); } else if (score.TreatAveragePoints == 0) { playerAct.Append($"/speak Lewis \"{i18n.Get("AnimalContest.Dialog.PlayerAct.Lewis.DisqualifyTreatAverage", new { animalName })}\""); } else if (score.FriendshipPoints == 0) { playerAct.Append($"/speak Lewis \"{i18n.Get("AnimalContest.Dialog.PlayerAct.Lewis.DisqualifyFriendship")}\""); } else { if (score.ParentWinnerPoints > 0) { playerAct.Append($"/pause 500/speak Lewis \"{i18n.Get("AnimalContest.Dialog.PlayerAct.Lewis.ParentWinner", new { animalName })}\""); } playerAct.Append($"/pause 800"); if (score.MonthsOld <= 1) { playerAct.Append($"/speak Lewis \"{i18n.Get("AnimalContest.Dialog.PlayerAct.Lewis.Age1Young")}\""); } else if (score.MonthsOld <= 2) { playerAct.Append($"/speak Lewis \"{i18n.Get("AnimalContest.Dialog.PlayerAct.Lewis.Age2Young")}\""); } else if (score.MonthsOld <= 4) { playerAct.Append($"/speak Lewis \"{i18n.Get("AnimalContest.Dialog.PlayerAct.Lewis.Age3")}\""); } else if (score.MonthsOld <= 6) { playerAct.Append($"/speak Lewis \"{i18n.Get("AnimalContest.Dialog.PlayerAct.Lewis.Age2Old")}\""); } else if (score.MonthsOld <= 8) { playerAct.Append($"/speak Lewis \"{i18n.Get("AnimalContest.Dialog.PlayerAct.Lewis.Age1Old")}\""); } playerAct.Append($"/pause 800"); switch (score.FriendshipPoints) { case 1: case 2: playerAct.Append($"/speak Lewis \"{i18n.Get("AnimalContest.Dialog.PlayerAct.Lewis.Friendship1&2", new { animalName })}\""); break; case 3: playerAct.Append($"/speak Lewis \"{i18n.Get("AnimalContest.Dialog.PlayerAct.Lewis.Friendship3", new { animalName })}\""); break; case 4: playerAct.Append($"/speak Lewis \"{i18n.Get("AnimalContest.Dialog.PlayerAct.Lewis.Friendship4")}\""); break; case 5: default: playerAct.Append($"/speak Lewis \"{i18n.Get("AnimalContest.Dialog.PlayerAct.Lewis.Friendship5")}\""); break; } playerAct.Append($"/pause 800"); switch (score.TreatVariatyPoints) { case 1: string shortDisplayType = farmAnimal.shortDisplayType().ToLower(); playerAct.Append($"/speak Lewis \"{i18n.Get("AnimalContest.Dialog.PlayerAct.Lewis.TreatVariaty1", new { shortDisplayType })}"); break; case 2: playerAct.Append($"/speak Lewis \"{i18n.Get("AnimalContest.Dialog.PlayerAct.Lewis.TreatVariaty2")}"); break; case 3: default: playerAct.Append($"/speak Lewis \"{i18n.Get("AnimalContest.Dialog.PlayerAct.Lewis.TreatVariaty3")}"); break; } playerAct.Append("#$b#"); string conjunction; switch (score.TreatAveragePoints) { case 1: conjunction = score.TreatVariatyPoints < 3 ? i18n.Get("AnimalContest.Dialog.PlayerAct.Lewis.TreatAverage1.Conjunction1") : i18n.Get("AnimalContest.Dialog.PlayerAct.Lewis.TreatAverage1.Conjunction2"); playerAct.Append($"{i18n.Get("AnimalContest.Dialog.PlayerAct.Lewis.TreatAverage1", new { conjunction })}\""); break; case 2: playerAct.Append($"{i18n.Get("AnimalContest.Dialog.PlayerAct.Lewis.TreatAverage2", new { animalName })}\""); break; case 3: default: conjunction = score.TreatVariatyPoints < 3 ? i18n.Get("AnimalContest.Dialog.PlayerAct.Lewis.TreatAverage3.Conjunction1") : i18n.Get("AnimalContest.Dialog.PlayerAct.Lewis.TreatAverage3.Conjunction2"); playerAct.Append($"{i18n.Get("AnimalContest.Dialog.PlayerAct.Lewis.TreatAverage3", new { conjunction })}\""); break; } playerAct.Append($"/pause 200"); if (score.TotalPoints >= DataLoader.AnimalContestData.MinPointsToPossibleWin) { playerAct.Append($"/speak Lewis \"{i18n.Get("AnimalContest.Dialog.PlayerAct.Lewis.ChanceWinning")}\""); playerAct.Append("/emote farmer 32"); } else { playerAct.Append($"/speak Lewis \"{i18n.Get("AnimalContest.Dialog.PlayerAct.Lewis.BetterNextTime")}\""); playerAct.Append("/emote farmer 28"); } } } else { playerAct.Append($"/speak Lewis \"{i18n.Get("AnimalContest.Dialog.PlayerAct.Lewis.Pet")}\""); string petName = Game1.player.getPetDisplayName(); string petSound = Game1.player.catPerson ? i18n.Get("AnimalContest.Dialog.PlayerAct.PetSound.Cat") : i18n.Get("AnimalContest.Dialog.PlayerAct.PetSound.Dog"); playerAct.Append($"/question null \"{i18n.Get("AnimalContest.Dialog.PlayerAct.Player.PetAnswers", new { petName, petSound })}\""); playerAct.Append($"/splitSpeak Lewis \"{i18n.Get("AnimalContest.Dialog.PlayerAct.Lewis.PetAnswers")}\""); playerAct.Append("/emote farmer 28"); } playerAct.Append($"/speak Lewis \"{i18n.Get("AnimalContest.Dialog.PlayerAct.Lewis.Ending")}\""); return(playerAct.ToString()); }
public static List<Item> CreateMeat(FarmAnimal farmAnimal) { List<Item> itemsToReturn = new List<Item>(); Animal animal; Animal? foundAnimal = AnimalExtension.GetAnimalFromType(farmAnimal.type.Value); if (foundAnimal == null || !CanGetMeatFrom(farmAnimal)) { return itemsToReturn; } else { animal = (Animal)foundAnimal; } AnimalItem animalItem = DataLoader.AnimalData.GetAnimalItem(farmAnimal); int minimumNumberOfMeat; int maxNumberOfMeat; int meatPrice; int debrisType; if (animal == Animal.Dinosaur) { if (DataLoader.ModConfig.DisableMeatFromDinosaur) { return itemsToReturn; } var meats = Enum.GetValues(typeof(Meat)); Meat meat = ((Meat)meats.GetValue(new Random((int)farmAnimal.myID.Value).Next(meats.Length))); meatPrice = DataLoader.MeatData.getMeatItem(meat).Price; minimumNumberOfMeat = 1; maxNumberOfMeat = 1 + (1300 / meatPrice); debrisType = (int)meat; } else if (animal == Animal.CustomAnimal) { MeatAnimalItem meatAnimalItem = (MeatAnimalItem) animalItem; debrisType = farmAnimal.meatIndex.Value; if (Enum.IsDefined(typeof(Meat), debrisType)) { meatPrice = DataLoader.MeatData.getMeatItem((Meat)debrisType).Price; } else { var objects = DataLoader.Helper.Content.Load<Dictionary<int, string>>("Data\\ObjectInformation", ContentSource.GameContent); meatPrice = Convert.ToInt32(objects[debrisType].Split('/')[1]); } minimumNumberOfMeat = meatAnimalItem.MinimalNumberOfMeat; maxNumberOfMeat = meatAnimalItem.MaximumNumberOfMeat; } else { MeatAnimalItem meatAnimalItem = (MeatAnimalItem) animalItem; Meat meat = animal.GetMeat(); meatPrice = DataLoader.MeatData.getMeatItem(meat).Price; minimumNumberOfMeat = meatAnimalItem.MinimalNumberOfMeat; maxNumberOfMeat = meatAnimalItem.MaximumNumberOfMeat; debrisType = (int)meat; } var numberOfMeat = minimumNumberOfMeat; numberOfMeat += (int)((farmAnimal.getSellPrice() / ((double)farmAnimal.price.Value) - 0.3) * (maxNumberOfMeat - minimumNumberOfMeat)); Random random = new Random((int)farmAnimal.myID.Value * 10000 + (int)Game1.stats.DaysPlayed); int[] quality = { 0, 0, 0, 0, 0 }; for (int i = 0; i < numberOfMeat; i++) { var produceQuality = ProduceQuality(random, farmAnimal); quality[produceQuality]++; } var tempTotal = meatPrice * quality[0] + meatPrice * quality[1] * 1.25 + meatPrice * quality[2] * 1.5 + meatPrice * quality[4] * 2; while (tempTotal < farmAnimal.getSellPrice() && quality[4] != numberOfMeat) { if (numberOfMeat < maxNumberOfMeat) { numberOfMeat++; quality[0]++; tempTotal += meatPrice; } else if (quality[0] > 0) { quality[0]--; quality[1]++; tempTotal += meatPrice * 0.25; } else if ((quality[1] > 0)) { quality[1]--; quality[2]++; tempTotal += meatPrice * 0.25; } else if ((quality[2] > 0)) { quality[2]--; quality[4]++; tempTotal += meatPrice * 0.50; } } for (; numberOfMeat > 0; --numberOfMeat) { Object newItem = new Object(Vector2.Zero, debrisType, 1); newItem.Quality = quality[4] > 0 ? 4 : quality[2] > 0 ? 2 : quality[1] > 0 ? 1 : 0; quality[newItem.Quality]--; itemsToReturn.Add(newItem); } if (animalItem is WoolAnimalItem woolAnimalItem) { int numberOfWools = farmAnimal.currentProduce.Value > 0 ? 1 : 0; numberOfWools += (int)(woolAnimalItem.MinimumNumberOfExtraWool + (farmAnimal.getSellPrice() / ((double)farmAnimal.price.Value) - 0.3) * (woolAnimalItem.MaximumNumberOfExtraWool - woolAnimalItem.MinimumNumberOfExtraWool)); for (; numberOfWools > 0; --numberOfWools) { Object newItem = new Object(Vector2.Zero, farmAnimal.defaultProduceIndex.Value, 1); newItem.Quality = ProduceQuality(random, farmAnimal); itemsToReturn.Add(newItem); } } if (animalItem is FeatherAnimalItem featherAnimalItem) { int numberOfFeather = (int)(featherAnimalItem.MinimumNumberOfFeatherChances + (farmAnimal.getSellPrice() / ((double)farmAnimal.price.Value) - 0.3) * (featherAnimalItem.MaximumNumberOfFeatherChances - featherAnimalItem.MinimumNumberOfFeatherChances)); float num1 = (int)farmAnimal.happiness.Value > 200 ? (float)farmAnimal.happiness.Value * 1.5f : ((int)farmAnimal.happiness.Value <= 100 ? (float)((int)farmAnimal.happiness.Value - 100) : 0.0f); for (; numberOfFeather > 0; --numberOfFeather) { if (random.NextDouble() < (double)farmAnimal.happiness.Value / 150.0) { if (random.NextDouble() < ((double)farmAnimal.friendshipTowardFarmer.Value + (double)num1) / 5000.0 + Game1.player.DailyLuck + (double)Game1.player.LuckLevel * 0.01) { Object newItem = new Object(Vector2.Zero, farmAnimal.deluxeProduceIndex.Value, 1); newItem.Quality = ProduceQuality(random, farmAnimal); itemsToReturn.Add(newItem); } } } } if (animalItem is FeetAnimalItem feetAnimalItem) { int numberOfFeet = (int)(feetAnimalItem.MinimumNumberOfFeetChances + (farmAnimal.getSellPrice() / ((double)farmAnimal.price.Value) - 0.3) * (feetAnimalItem.MaximumNumberOfFeetChances - feetAnimalItem.MinimumNumberOfFeetChances)); float num1 = (int)farmAnimal.happiness.Value > 200 ? (float)farmAnimal.happiness.Value * 1.5f : ((int)farmAnimal.happiness.Value <= 100 ? (float)((int)farmAnimal.happiness.Value - 100) : 0.0f); for (; numberOfFeet > 0; --numberOfFeet) { if (random.NextDouble() < (double)farmAnimal.happiness.Value / 150.0) { if (random.NextDouble() < ((double)farmAnimal.friendshipTowardFarmer.Value + (double)num1) / 5000.0 + Game1.player.DailyLuck + (double)Game1.player.LuckLevel * 0.01) { Object newItem = new Object(Vector2.Zero, farmAnimal.deluxeProduceIndex.Value, 1); newItem.Quality = ProduceQuality(random, farmAnimal); itemsToReturn.Add(newItem); } } } } if (AnimalContestController.CanChangeParticipant(farmAnimal)) { AnimalContestController.RemoveAnimalParticipant(farmAnimal); itemsToReturn.Add(ToolsFactory.GetParticipantRibbon()); } return itemsToReturn; }
public static List <Item> CreateMeat(FarmAnimal farmAnimal) { List <Item> itemsToReturn = new List <Item>(); Animal animal; Animal?foundAnimal = AnimalExtension.GetAnimalFromType(farmAnimal.type.Value); if (foundAnimal == null) { return(itemsToReturn); } else { animal = (Animal)foundAnimal; } AnimalItem animalItem; Meat meat; int minimumNumberOfMeat; int maxNumberOfMeat; int meatPrice; if (animal == Animal.Dinosaur) { if (DataLoader.ModConfig.DisableMeatFromDinosaur) { return(itemsToReturn); } animalItem = null; var meats = Enum.GetValues(typeof(Meat)); meat = ((Meat)meats.GetValue(new Random((int)farmAnimal.myID.Value).Next(meats.Length))); minimumNumberOfMeat = 1; meatPrice = DataLoader.MeatData.getMeatItem(meat).Price; maxNumberOfMeat = 1 + (1300 / meatPrice); } else { animalItem = DataLoader.AnimalData.getAnimalItem(animal); meat = animal.GetMeat(); minimumNumberOfMeat = animalItem.MinimalNumberOfMeat; meatPrice = DataLoader.MeatData.getMeatItem(meat).Price; maxNumberOfMeat = animalItem.MaximumNumberOfMeat; } var debrisType = (int)meat; var numberOfMeat = minimumNumberOfMeat; numberOfMeat += (int)((farmAnimal.getSellPrice() / ((double)farmAnimal.price.Value) - 0.3) * (maxNumberOfMeat - minimumNumberOfMeat)); Random random = new Random((int)farmAnimal.myID.Value * 10000 + (int)Game1.stats.DaysPlayed); int[] quality = { 0, 0, 0, 0, 0 }; for (int i = 0; i < numberOfMeat; i++) { var produceQuality = ProduceQuality(random, farmAnimal); quality[produceQuality]++; } var tempTotal = meatPrice * quality[0] + meatPrice * quality[1] * 1.25 + meatPrice * quality[2] * 1.5 + meatPrice * quality[4] * 2; while (tempTotal < farmAnimal.getSellPrice() && quality[4] != numberOfMeat) { if (numberOfMeat < maxNumberOfMeat) { numberOfMeat++; quality[0]++; tempTotal += meatPrice; } else if (quality[0] > 0) { quality[0]--; quality[1]++; tempTotal += meatPrice * 0.25; } else if ((quality[1] > 0)) { quality[1]--; quality[2]++; tempTotal += meatPrice * 0.25; } else if ((quality[2] > 0)) { quality[2]--; quality[4]++; tempTotal += meatPrice * 0.50; } } for (; numberOfMeat > 0; --numberOfMeat) { Object newItem = new Object(Vector2.Zero, debrisType, 1); newItem.Quality = quality[4] > 0 ? 4 : quality[2] > 0 ? 2 : quality[1] > 0 ? 1 : 0; quality[newItem.Quality]--; itemsToReturn.Add(newItem); } if ((animal == Animal.Sheep || animal == Animal.Rabbit)) { WoolAnimalItem woolAnimalItem = (WoolAnimalItem)animalItem; int numberOfWools = farmAnimal.currentProduce.Value > 0 ? 1 : 0; numberOfWools += (int)(woolAnimalItem.MinimumNumberOfExtraWool + (farmAnimal.getSellPrice() / ((double)farmAnimal.price.Value) - 0.3) * (woolAnimalItem.MaximumNumberOfExtraWool - woolAnimalItem.MinimumNumberOfExtraWool)); for (; numberOfWools > 0; --numberOfWools) { Object newItem = new Object(Vector2.Zero, farmAnimal.defaultProduceIndex.Value, 1); newItem.Quality = ProduceQuality(random, farmAnimal); itemsToReturn.Add(newItem); } } if (animal == Animal.Duck) { FeatherAnimalItem featherAnimalItem = (FeatherAnimalItem)animalItem; int numberOfFeather = (int)(featherAnimalItem.MinimumNumberOfFeatherChances + (farmAnimal.getSellPrice() / ((double)farmAnimal.price.Value) - 0.3) * (featherAnimalItem.MaximumNumberOfFeatherChances - featherAnimalItem.MinimumNumberOfFeatherChances)); float num1 = (int)farmAnimal.happiness.Value > 200 ? (float)farmAnimal.happiness.Value * 1.5f : ((int)farmAnimal.happiness.Value <= 100 ? (float)((int)farmAnimal.happiness.Value - 100) : 0.0f); for (; numberOfFeather > 0; --numberOfFeather) { if (random.NextDouble() < (double)farmAnimal.happiness.Value / 150.0) { if (random.NextDouble() < ((double)farmAnimal.friendshipTowardFarmer.Value + (double)num1) / 5000.0 + Game1.dailyLuck + (double)Game1.player.LuckLevel * 0.01) { Object newItem = new Object(Vector2.Zero, farmAnimal.deluxeProduceIndex.Value, 1); newItem.Quality = ProduceQuality(random, farmAnimal); itemsToReturn.Add(newItem); } } } } if (animal == Animal.Rabbit) { FeetAnimalItem feetAnimalItem = (FeetAnimalItem)animalItem; int numberOfFeet = (int)(feetAnimalItem.MinimumNumberOfFeetChances + (farmAnimal.getSellPrice() / ((double)farmAnimal.price.Value) - 0.3) * (feetAnimalItem.MaximumNumberOfFeetChances - feetAnimalItem.MinimumNumberOfFeetChances)); float num1 = (int)farmAnimal.happiness.Value > 200 ? (float)farmAnimal.happiness.Value * 1.5f : ((int)farmAnimal.happiness.Value <= 100 ? (float)((int)farmAnimal.happiness.Value - 100) : 0.0f); for (; numberOfFeet > 0; --numberOfFeet) { if (random.NextDouble() < (double)farmAnimal.happiness.Value / 150.0) { if (random.NextDouble() < ((double)farmAnimal.friendshipTowardFarmer.Value + (double)num1) / 5000.0 + Game1.dailyLuck + (double)Game1.player.LuckLevel * 0.01) { Object newItem = new Object(Vector2.Zero, farmAnimal.deluxeProduceIndex.Value, 1); newItem.Quality = ProduceQuality(random, farmAnimal); itemsToReturn.Add(newItem); } } } } return(itemsToReturn); }
public static TreatItem GetTreatItem(FarmAnimal farmAnimal) { Animal?foundAnimal = AnimalExtension.GetAnimalFromType(farmAnimal.type.Value); return(DataLoader.AnimalData.getAnimalItem((Animal)foundAnimal) as TreatItem); }