public SimpleCharacterWindow(CampaignState state, Guid?guid = null) { this.valid = false; this.state = state.copy(); this.actions = new List <EntryAction>(); if (guid is null) { ActionCharacterSet add_action = new ActionCharacterSet(Guid.NewGuid(), null, new Character("")); this.actions.Add(add_action); this.character = add_action.to; } else { this.character = this.state.characters.characters[guid.Value]; } this.guid = guid; this.property_rows = new ObservableCollection <PropertyRow>(); this.populate_property_rows(this.property_rows, new List <string>(), this.character.properties); this.selected_path = null; this.selected_prop = null; this.selected_member = null; InitializeComponent(); this.name_box.Text = this.character.name; this.properties_list.ItemsSource = this.property_rows; }
public void test_copy() { Character chr = new Character("Somebody"); Note note = new Note("Some note", Guid.NewGuid()); Task task = new Task(Guid.NewGuid(), "Some task"); CalendarEvent evt = new CalendarEvent(Guid.NewGuid(), 42, "Some event"); CampaignState foo = new CampaignState(), bar; Guid chr_guid = foo.characters.add_character(chr); Guid inv_guid = foo.inventories.new_inventory("Somebody's Inventory"); foo.character_inventory[chr_guid] = inv_guid; Guid note_guid = foo.notes.add_note(note); Guid task_guid = foo.tasks.add_task(task); Guid event_guid = foo.events.add_event(evt); bar = foo.copy(); Assert.IsFalse(ReferenceEquals(foo, bar)); Assert.IsFalse(ReferenceEquals(foo.characters, bar.characters)); Assert.AreEqual(foo.characters.characters.Count, bar.characters.characters.Count); Assert.IsTrue(bar.characters.characters.ContainsKey(chr_guid)); Assert.AreEqual(bar.characters.characters[chr_guid].name, "Somebody"); Assert.IsFalse(ReferenceEquals(foo.inventories, bar.inventories)); Assert.AreEqual(foo.inventories.inventories.Count, bar.inventories.inventories.Count); Assert.IsTrue(bar.inventories.inventories.ContainsKey(inv_guid)); Assert.AreEqual(bar.inventories.inventories[inv_guid].name, "Somebody's Inventory"); Assert.IsFalse(ReferenceEquals(foo.character_inventory, bar.character_inventory)); Assert.AreEqual(foo.character_inventory.Count, bar.character_inventory.Count); Assert.IsTrue(bar.character_inventory.ContainsKey(chr_guid)); Assert.AreEqual(bar.character_inventory[chr_guid], inv_guid); Assert.IsFalse(ReferenceEquals(foo.notes, bar.notes)); Assert.AreEqual(foo.notes.notes.Count, bar.notes.notes.Count); Assert.IsTrue(bar.notes.notes.ContainsKey(note_guid)); Assert.AreEqual(bar.notes.notes[note_guid].contents, "Some note"); Assert.IsFalse(ReferenceEquals(foo.tasks, bar.tasks)); Assert.AreEqual(foo.tasks.tasks.Count, bar.tasks.tasks.Count); Assert.IsTrue(bar.tasks.tasks.ContainsKey(task_guid)); Assert.AreEqual(bar.tasks.tasks[task_guid].name, "Some task"); Assert.IsFalse(ReferenceEquals(foo.events, bar.events)); Assert.AreEqual(foo.events.events.Count, bar.events.events.Count); Assert.IsTrue(bar.events.events.ContainsKey(event_guid)); Assert.AreEqual(bar.events.events[event_guid].name, "Some event"); }
public TopicWindow( Dictionary <Guid, List <EntityRow> > topic_cache, Dictionary <Guid, Topic> topics, CampaignSave save_state, CampaignState state, decimal now, Guid?entry_guid = null, Guid?guid = null ) { this.valid = false; this.topic_cache = topic_cache; this.topics = new Dictionary <Guid, Topic>(topics); this.save_state = save_state; this.state = state.copy(); this.now = now; this.entry_guid = entry_guid; this.actions = new List <EntryAction>(); this.notes = new Dictionary <Guid, ExternalNote>(save_state.domain.notes); this.topic_refs = new Dictionary <Guid, int>(); this.history = new Stack <Guid>(); if (guid is null) { if (entry_guid is null) { throw new ArgumentNullException(nameof(entry_guid)); } this.guid = Guid.NewGuid(); this.topics[this.guid] = new Topic(""); } else { this.guid = guid.Value; } if (topic_cache.Count <= 0) { this.populate_topic_cache(); } InitializeComponent(); this.set_topic(this.guid); }