private void GameLoop_UpdateTicked(object sender, StardewModdingAPI.Events.UpdateTickedEventArgs e) { if (!Context.IsWorldReady) { return; } if (sw.ElapsedMilliseconds >= 1000 * config.Time) { Ring r = new Ring(); int ID = rand.Next(0, 930); Item o = new Object(ID, config.Stack); while (o.Name is "???" or "Error Item" or "Weeds" || o.getDescription() is "..." or "???") { o = new Object(rand.Next(0, 930), config.Stack); } if (o.Category == -96 || o.DisplayName.Contains("Ring") || o.DisplayName is "Iridium Band" or "Immunity Band") { o = new Ring(ID); } if (Game1.player.freeSpotsInInventory() != 0) { Game1.player.addItemToInventory(o); } else { Game1.player.currentLocation.debris.Add(new Debris(o, Game1.player.getStandingPosition())); Monitor.Log($"Added object {o.Name} at {Game1.player.getStandingPosition()}."); } sw.Restart(); } }
public static ValMap ToMap(StardewValley.Object obj) { var result = new ValMap(); string type = obj.Type; if (type == "asdf") { type = obj.Name; // because, c'mon. } result.map[_type] = new ValString(type); // ToDo: limit the following to ones that really apply for this type. result.map[_name] = new ValString(obj.Name); result["displayName"] = new ValString(obj.DisplayName); result["health"] = new ValNumber(obj.getHealth()); if (obj.isLamp.Get()) { result["isOn"] = ValNumber.Truth(obj.IsOn); } result["quality"] = new ValNumber(obj.Quality); result.map[_harvestable] = ValNumber.Truth(obj.readyForHarvest.Get()); result["minutesTillReady"] = new ValNumber(obj.MinutesUntilReady); result["value"] = new ValNumber(obj.sellToStorePrice()); result["description"] = new ValString(obj.getDescription()); return(result); }
public static void DumpObject(string sName, SDVObject oObject) { if (oObject == null) { LogTrace("SDVObject " + sName, " is null"); } else { LogTrace("SDVObject " + sName, "Dump"); DumpObject(" Type", oObject.GetType().Name); DumpObject(" name", oObject.Name); DumpObject(" displayname", oObject.DisplayName); DumpObject(" category", oObject.category.Value); DumpObject(" parentindex", oObject.parentSheetIndex.Value); DumpObject(" description", oObject.getDescription()); DumpObject(" contexttags value", oObject.GetContextTagList()); DumpObject(" parentSheetIndex", oObject.parentSheetIndex.Value); DumpObject(" heldObject", oObject.heldObject.Value == null ? "Nothing" : oObject.heldObject.Value.displayName ?? oObject.heldObject.Value.name); DumpObject(" preservedParentSheetIndex", oObject.preservedParentSheetIndex); } }
public override string getDescription() { return(Item.getDescription()); }
public static IList <Fish> GetFishForToday() { var fish = Game1.content.Load <Dictionary <int, string> >("Data\\Fish"); var neededItems = new List <int>(); CommunityCenter cc = Game1.locations.OfType <CommunityCenter>().SingleOrDefault(); // get fish still needed for cc bundles if (cc != null && !Game1.MasterPlayer.mailReceived.Contains("JojaMember") && !cc.areAllAreasComplete()) { foreach (var b in Game1.content.Load <Dictionary <string, string> >("Data\\Bundles")) { var bid = int.Parse(b.Key.Split('/')[1]); var items = b.Value.Split('/')[2].Split(' ').GroupsOf(3).Select(y => y.First()).ToList(); for (var i = 0; i < items.Count; i++) { if (cc.bundles[bid][i]) { continue; } var itemId = int.Parse(items[i]); var objectToAdd = new Object(Vector2.Zero, itemId, 1); if (objectToAdd.Name.Contains("rror") || objectToAdd.Category != -4) { continue; } neededItems.Add(itemId); } } } var locations = Game1.content.Load <Dictionary <string, string> >("Data\\Locations") .Where(x => x.Key != "fishingGame" && x.Key != "Temp" && x.Key != "Backwoods"); var fishField = 4 + Utility.getSeasonNumber(Game1.currentSeason); return(fish.Where(x => !x.Value.Contains("/trap/")) .Select(x => { var parts = x.Value.Split('/'); var o = new StardewValley.Object(x.Key, 1); return new Fish { ID = x.Key, Name = parts[0], Difficulty = int.Parse(parts[1]), Description = o.getDescription().Replace("\r\n", ""), Times = parts[5].Split(' ').GroupsOf(2).Select(y => string.Join("-", y)).ToArray(), MinLevel = int.Parse(parts[12]), Weather = parts[7], NumSeasons = parts[6].Split(' ').Length, NeedForCC = neededItems.Contains(x.Key), NeedForCollection = !Game1.player.fishCaught.ContainsKey(x.Key), Locations = locations.Where(y => { var fishes = y.Value.Split('/')[fishField]; return fishes.Contains(x.Key.ToString()); }).Select(y => y.Key).ToArray(), }; }) // filter for today's weather .Where(x => x.Weather == "both" || (x.Weather == "rainy") == (Game1.isRaining)) // filter for those with valid locations this season .Where(x => x.Locations.Length > 0) .OrderByDescending(x => x.NeedForCC) // all cc fish first .ThenByDescending(x => x.NeedForCollection || x.NeedForCC) // then unmet collection requirements .ThenByDescending(x => x.Weather == "rainy") // rainy day fish higher on rainy days get highest priority .ThenBy(x => x.NumSeasons) // fewer seasons makes it more urgent .ThenBy(x => x.Difficulty) // easiest first .ToList()); }