public override void Execute() { RetCode rc; Debug.Assert(GetAll || DobjArtifact != null); if (GetAll) { // screen out all weapons in the room which have monsters present with affinities to those weapons TakenArtifactList = ActorRoom.GetTakeableList().Where(a => gEngine.GetMonsterList(m => m.IsInRoom(ActorRoom) && m.Weapon == -a.Uid - 1 && m != ActorMonster).FirstOrDefault() == null).ToList(); } else { TakenArtifactList = new List <IArtifact>() { DobjArtifact }; } if (TakenArtifactList.Count <= 0) { gOut.Print("There's nothing for you to get."); NextState = Globals.CreateInstance <IStartState>(); goto Cleanup; } ArtTypes = new ArtifactType[] { ArtifactType.DisguisedMonster, ArtifactType.DeadBody, ArtifactType.BoundMonster, ArtifactType.Weapon, ArtifactType.MagicWeapon }; NewlineFlag = false; foreach (var artifact in TakenArtifactList) { DobjArtAc = artifact.GetArtifactCategory(ArtTypes, false); if (DobjArtAc == null) { DobjArtAc = artifact.GetCategories(0); } Debug.Assert(DobjArtAc != null); OmitWeightCheck = artifact.IsCarriedByCharacter(true); ProcessArtifact(artifact, DobjArtAc, ref _newlineFlag); if (artifact.IsCarriedByCharacter()) { // when a weapon is picked up all monster affinities to that weapon are broken FumbleMonsterList = gEngine.GetMonsterList(m => m.Weapon == -artifact.Uid - 1 && m != ActorMonster); foreach (var monster in FumbleMonsterList) { monster.Weapon = -1; } WeaponArtifactAc = artifact.GeneralWeapon; if (artifact.IsReadyableByCharacter() && (WeaponArtifact == null || gEngine.WeaponPowerCompare(artifact, WeaponArtifact) > 0) && (!GetAll || TakenArtifactList.Count == 1 || gGameState.Sh < 1 || WeaponArtifactAc.Field5 < 2)) { WeaponArtifact = artifact; } } } if (NewlineFlag) { gOut.WriteLine(); NewlineFlag = false; } if (ActorRoom.IsLit()) { if (!gEngine.AutoDisplayUnseenArtifactDescs && !GetAll && DobjArtifact.IsCarriedByCharacter() && !DobjArtifact.Seen) { Globals.Buf.Clear(); rc = DobjArtifact.BuildPrintedFullDesc(Globals.Buf, false); Debug.Assert(gEngine.IsSuccess(rc)); gOut.Write("{0}", Globals.Buf); DobjArtifact.Seen = true; } } if (ActorMonster.Weapon <= 0 && WeaponArtifact != null && NextState == null) { RedirectCommand = Globals.CreateInstance <IReadyCommand>(); CopyCommandData(RedirectCommand); RedirectCommand.Dobj = WeaponArtifact; NextState = RedirectCommand; } Cleanup: if (NextState == null) { NextState = Globals.CreateInstance <IMonsterStartState>(); } }
public override void Execute() { RetCode rc; Debug.Assert(DobjArtifact != null || DobjMonster != null); if (DobjMonster != null) { Globals.Buf.Clear(); rc = DobjMonster.BuildPrintedFullDesc(Globals.Buf, false); Debug.Assert(gEngine.IsSuccess(rc)); gOut.Write("{0}", Globals.Buf); DobjMonster.Seen = true; if (DobjMonster.Reaction == Friendliness.Friend && DobjMonster.ShouldShowContentsWhenExamined()) { RedirectCommand01 = Globals.CreateInstance <IInventoryCommand>(); CopyCommandData(RedirectCommand01); NextState = RedirectCommand01; goto Cleanup; } if (DobjMonster.ShouldShowHealthStatusWhenExamined()) { IsUninjuredGroupMonster = DobjMonster.CurrGroupCount > 1 && DobjMonster.DmgTaken == 0; Globals.Buf.SetFormat("{0}{1} {2} ", Environment.NewLine, IsUninjuredGroupMonster ? "They" : DobjMonster.GetTheName(true, true, false, true, Globals.Buf01), IsUninjuredGroupMonster ? "are" : "is"); DobjMonster.AddHealthStatus(Globals.Buf); gOut.Write("{0}", Globals.Buf); } goto Cleanup; } DobjArtAc = DobjArtifact.GetArtifactCategory(ArtTypes, false); if (DobjArtAc == null) { DobjArtAc = DobjArtifact.GetCategories(0); } Debug.Assert(DobjArtAc != null); if (DobjArtifact.IsEmbeddedInRoom(ActorRoom)) { DobjArtifact.SetInRoom(ActorRoom); } if (DobjArtAc.Type == ArtifactType.DoorGate) { DobjArtAc.Field4 = 0; } if (DobjArtAc.Type == ArtifactType.DisguisedMonster) { gEngine.RevealDisguisedMonster(ActorRoom, DobjArtifact); NextState = Globals.CreateInstance <IStartState>(); goto Cleanup; } Globals.Buf.Clear(); if (!Enum.IsDefined(typeof(ContainerType), ContainerType) || DobjArtifact.IsWornByCharacter()) { rc = DobjArtifact.BuildPrintedFullDesc(Globals.Buf, false); Debug.Assert(gEngine.IsSuccess(rc)); gOut.Write("{0}", Globals.Buf); DobjArtifact.Seen = true; ProcessEvents(EventType.AfterPrintArtifactFullDesc); if (GotoCleanup) { goto Cleanup; } if ((DobjArtAc.Type == ArtifactType.Drinkable || DobjArtAc.Type == ArtifactType.Edible) && DobjArtAc.Field2 != Constants.InfiniteDrinkableEdible) { gOut.Print("There {0}{1}{2}{3} left.", DobjArtAc.Field2 != 1 ? "are " : "is ", DobjArtAc.Field2 > 0 ? gEngine.GetStringFromNumber(DobjArtAc.Field2, false, Globals.Buf) : "no", DobjArtAc.Type == ArtifactType.Drinkable ? " swallow" : " bite", DobjArtAc.Field2 != 1 ? "s" : ""); } if (((DobjArtAc.Type == ArtifactType.InContainer && (DobjArtAc.IsOpen() || DobjArtifact.ShouldExposeInContentsWhenClosed())) || DobjArtAc.Type == ArtifactType.OnContainer || DobjArtAc.Type == ArtifactType.UnderContainer || DobjArtAc.Type == ArtifactType.BehindContainer) && DobjArtifact.ShouldShowContentsWhenExamined()) { RedirectCommand = Globals.CreateInstance <IInventoryCommand>(x => { x.AllowExtendedContainers = true; }); CopyCommandData(RedirectCommand); NextState = RedirectCommand; goto Cleanup; } goto Cleanup; } ContainerArtType = gEngine.EvalContainerType(ContainerType, ArtifactType.InContainer, ArtifactType.OnContainer, ArtifactType.UnderContainer, ArtifactType.BehindContainer); DobjArtContainerAc = DobjArtifact.GetArtifactCategory(ContainerArtType); if (DobjArtContainerAc == null) { PrintYouSeeNothingSpecial(); goto Cleanup; } if (DobjArtContainerAc == DobjArtifact.InContainer && !DobjArtContainerAc.IsOpen() && !DobjArtifact.ShouldExposeInContentsWhenClosed()) { PrintMustFirstOpen(DobjArtifact); NextState = Globals.CreateInstance <IStartState>(); goto Cleanup; } ContainerArtifactList = DobjArtifact.GetContainedList(containerType: ContainerType); ShowCharOwned = !DobjArtifact.IsCarriedByCharacter() /* && !DobjArtifact.IsWornByCharacter() */; if (ContainerArtifactList.Count > 0) { Globals.Buf.SetFormat("{0}{1} {2} you see ", Environment.NewLine, gEngine.EvalContainerType(ContainerType, "Inside", "On", "Under", "Behind"), DobjArtifact.GetTheName(false, ShowCharOwned, false, false, Globals.Buf01)); rc = gEngine.GetRecordNameList(ContainerArtifactList.Cast <IGameBase>().ToList(), ArticleType.A, ShowCharOwned, StateDescDisplayCode.None, false, false, Globals.Buf); Debug.Assert(gEngine.IsSuccess(rc)); } else { Globals.Buf.SetFormat("{0}There's nothing {1} {2}", Environment.NewLine, gEngine.EvalContainerType(ContainerType, "inside", "on", "under", "behind"), DobjArtifact.GetTheName(false, ShowCharOwned, false, false, Globals.Buf01)); } Globals.Buf.AppendFormat(".{0}", Environment.NewLine); gOut.Write("{0}", Globals.Buf); ProcessEvents(EventType.AfterPrintArtifactContents); if (GotoCleanup) { goto Cleanup; } Cleanup: if (NextState == null) { NextState = Globals.CreateInstance <IMonsterStartState>(); } }