private static void Dump(this IVillager v, string path) { var name = GameInfo.Strings.GetVillager(v.InternalName); var dest = Path.Combine(path, $"{name}.{v.Extension}"); File.WriteAllBytes(dest, v.Write()); }
public VillagerMemoryEditor(IVillager villager) { InitializeComponent(); this.TranslateInterface(GameInfo.CurrentLanguage); Greetings = new[] { TB_Greeting, TB_Greeting1, TB_Greeting2, TB_Greeting3, TB_Greeting4, TB_Greeting5, TB_Greeting6, TB_Greeting7, TB_Greeting8, TB_Greeting9, TB_Greeting10 }; Villager = villager; Memories = villager.GetMemories(); for (int i = 0; i < Memories.Length; i++) { LB_Players.Items.Add($"{i} - {Memories[i].PlayerName} ({Memories[i].TownName})"); } LB_Players.SelectedIndex = 0; DialogResult = DialogResult.Cancel; LB_Counts.SelectedIndex = 0; }
private static void Dump(this VillagerHouse h, string path, IVillager v) { var name = GameInfo.Strings.GetVillager(v.InternalName); var dest = Path.Combine(path, $"{name}.nhvh"); var data = h.Data; File.WriteAllBytes(dest, data); }
public void TestSmallCrossRoadsStrategy(IVillager villager1, IVillager villager2, bool leftIsSafe) { var strat = new Strategies(leftIsSafe); var ans = strat.SmallIsLeftRoadSafe(villager1, villager2); Assert.Equal(leftIsSafe, ans); }
public void TestLargeCrossRoadsStrategy(IVillager villager1, IVillager villager2, IVillager villager3, bool leftIsSafe) { var strat = new Strategies(leftIsSafe); var ans = strat.LargeIsLeftRoadSafe(villager1, villager2, villager3); Assert.Equal(leftIsSafe, ans); }
private void LoadVillager(IVillager v) { Loading = true; NUD_Species.Value = v.Species; NUD_Variant.Value = v.Variant; CB_Personality.SelectedIndex = (int)v.Personality; TB_Catchphrase.Text = v.CatchPhrase; CHK_VillagerMovingOut.Checked = v.MovingOut; Loading = false; }
public bool LargeIsLeftRoadSafe(IVillager villager1, IVillager villager2, IVillager villager3) { var ans1 = villager1.Ask(PishPosh.Posh == villager1.Ask(villager3 is RandomGuy)); var nextVillager = ans1 == PishPosh.Posh ? villager2 : villager3; var ans2 = nextVillager.Ask(PishPosh.Posh == nextVillager.Ask(_leftIsSafe)); return(ans2 == PishPosh.Posh); }
public static void DumpVillagerMemoryPlayer(IVillager v, GSaveMemory memory) { using var sfd = new SaveFileDialog { Filter = "New Horizons Villager Player Memory (*.nhvpm)|*.nhvpm|All files (*.*)|*.*", FileName = $"{v.InternalName}.nhvpm", }; if (sfd.ShowDialog() != DialogResult.OK) { return; } var data = memory.Data; File.WriteAllBytes(sfd.FileName, data); }
public IEnumerator <object[]> GetEnumerator() { foreach (var language in new ILanguage[] { new PishMeansTrue(), new PoshMeansTrue() }) { foreach (var leftIsSafe in new[] { true, false }) { var villagers = new IVillager [] { new TruthTeller(language), new Liar(language) }; foreach (var villagerPerm in villagers.Permute()) { yield return(new object[] { villagerPerm[0], villagerPerm[1], leftIsSafe }); } } } }
public static bool LoadVillagerMemoryPlayer(IVillager v, GSaveMemory[] memories, int index) { using var ofd = new OpenFileDialog { Filter = "New Horizons Villager Player Memory (*.nhvpm)|*.nhvpm|All files (*.*)|*.*", FileName = $"{v.InternalName}.nhvpm", }; if (ofd.ShowDialog() != DialogResult.OK) { return(false); } var file = ofd.FileName; var fi = new FileInfo(file); const int expectLength = GSaveMemory.SIZE; if (fi.Length != expectLength) { WinFormsUtil.Error(MessageStrings.MsgCanceling, string.Format(MessageStrings.MsgDataSizeMismatchImport, fi.Length, expectLength)); return(false); } var data = File.ReadAllBytes(file); var memory = new GSaveMemory(data); var old = memories[index]; if (!memory.IsOriginatedFrom(old)) { string msg = string.Format(MessageStrings.MsgDataDidNotOriginateFromHost_0, old.PlayerName); var result = WinFormsUtil.Prompt(MessageBoxButtons.YesNoCancel, msg, MessageStrings.MsgAskUpdateValues); if (result == DialogResult.Cancel) { return(false); } if (result == DialogResult.Yes) { memory.ChangeOrigins(old, memory.Data); } } memories[index] = memory; return(true); }
public VillagerMemoryEditor(IVillager villager) { InitializeComponent(); this.TranslateInterface(GameInfo.CurrentLanguage); Greetings = new[] { TB_Greeting, TB_Greeting1, TB_Greeting2, TB_Greeting3, TB_Greeting4, TB_Greeting5, TB_Greeting6, TB_Greeting7, TB_Greeting8, TB_Greeting9, TB_Greeting10 }; Villager = villager; Memories = villager.GetMemories(); UpdatePlayerIslandStrings(); LB_Players.SelectedIndex = 0; DialogResult = DialogResult.Cancel; LB_Counts.SelectedIndex = 0; }
public VillagerDIYTimerEditor(IVillager v) { Villager = v; Hour = Villager.DIYEndHour; Minute = Villager.DIYEndMinute; Second = Villager.DIYEndSecond; InitializeComponent(); // Both hour and minute will be 255 in most cases when villager is idling. // If another villager's end time is earlier, this villager will not craft UNLESS the villager is crafting an "event" item, in which case it seems it will take priority. bool idleState = Hour == byte.MaxValue || Minute == byte.MaxValue; DT_Time.Value = idleState ? new DateTime(1970, 01, 01, 0, 0, 0) : new DateTime(1970, 01, 01, Hour, Minute, Second); CHK_Crafting.Checked = DT_Time.Enabled = !idleState; CB_Recipe.DisplayMember = nameof(ComboItem.Text); CB_Recipe.ValueMember = nameof(ComboItem.Value); CB_Recipe.DataSource = Recipes; RecipeIndex = Villager.DIYRecipeIndex; CB_Recipe.SelectedValue = (int)RecipeIndex; }
public bool SmallIsLeftRoadSafe(IVillager villager1, IVillager villager2) { var ans = villager1.Ask(PishPosh.Posh == villager1.Ask(_leftIsSafe)); return(ans == PishPosh.Posh); }