Beispiel #1
0
        public override void Execute()
        {
            Debug.Assert(DobjArtifact != null);

            // Crimson cloak boosts armor class

            if (DobjArtifact.Uid == 19 && DobjArtifact.IsCarriedByCharacter())
            {
                var armorArtifact = gGameState.Ar > 0 ? gADB[gGameState.Ar] : null;

                if (armorArtifact != null)
                {
                    armorArtifact.Wearable.Field1 += 2;
                }
                else
                {
                    DobjArtifact.Wearable.Field1 += 2;
                }
            }

            base.Execute();
        }
Beispiel #2
0
        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>();
            }
        }
Beispiel #3
0
        public override void Execute()
        {
            Debug.Assert(DobjArtifact != null);

            ProcessEvents(EventType.BeforeUseArtifact);

            if (GotoCleanup)
            {
                goto Cleanup;
            }

            DobjArtAc = DobjArtifact.GetArtifactCategory(ArtTypes, false);

            if (DobjArtAc == null)
            {
                PrintTryDifferentCommand(DobjArtifact);

                goto Cleanup;
            }

            if (DobjArtAc.IsWeapon01())
            {
                NextState = Globals.CreateInstance <IReadyCommand>();

                CopyCommandData(NextState as ICommand);

                goto Cleanup;
            }

            if (DobjArtAc.Type == ArtifactType.DisguisedMonster)
            {
                if (!DobjArtifact.IsUnmovable() && !DobjArtifact.IsCarriedByCharacter())
                {
                    if (DobjArtifact.IsCarriedByContainer())
                    {
                        PrintRemovingFirst(DobjArtifact);
                    }
                    else
                    {
                        PrintTakingFirst(DobjArtifact);
                    }
                }

                gEngine.RevealDisguisedMonster(ActorRoom, DobjArtifact);

                NextState = Globals.CreateInstance <IMonsterStartState>();

                goto Cleanup;
            }

            if (DobjArtAc.Type == ArtifactType.Drinkable)
            {
                NextState = Globals.CreateInstance <IDrinkCommand>();

                CopyCommandData(NextState as ICommand);

                goto Cleanup;
            }

            if (DobjArtAc.Type == ArtifactType.Edible)
            {
                NextState = Globals.CreateInstance <IEatCommand>();

                CopyCommandData(NextState as ICommand);

                goto Cleanup;
            }

            Debug.Assert(DobjArtAc.Type == ArtifactType.Wearable);

            NextState = Globals.CreateInstance <IWearCommand>();

            CopyCommandData(NextState as ICommand);

Cleanup:

            if (NextState == null)
            {
                NextState = Globals.CreateInstance <IMonsterStartState>();
            }
        }
Beispiel #4
0
        public override void Execute()
        {
            RetCode rc;

            Debug.Assert(DobjArtifact != null && IobjMonster != null);

            if (IobjMonster.Reaction < Friendliness.Friend)
            {
                gEngine.MonsterEmotes(IobjMonster);

                gOut.WriteLine();

                goto Cleanup;
            }

            if (!DobjArtifact.IsRequestable())
            {
                PrintObjBelongsToActor(DobjArtifact, IobjMonster);

                goto Cleanup;
            }

            if (!GetCommandCalled)
            {
                RedirectToGetCommand <IRequestCommand>(DobjArtifact, false);

                goto Cleanup;
            }

            if (!DobjArtifact.IsCarriedByCharacter())
            {
                if (DobjArtifact.DisguisedMonster == null)
                {
                    NextState = Globals.CreateInstance <IStartState>();
                }

                goto Cleanup;
            }

            if (IobjMonster.Weapon == DobjArtifact.Uid)
            {
                Debug.Assert(DobjArtifact.GeneralWeapon != null);

                rc = DobjArtifact.RemoveStateDesc(DobjArtifact.GetReadyWeaponDesc());

                Debug.Assert(gEngine.IsSuccess(rc));

                IobjMonster.Weapon = -1;
            }

            if (ActorMonster.Weapon <= 0 && DobjArtifact.IsReadyableByCharacter() && NextState == null)
            {
                NextState = Globals.CreateInstance <IReadyCommand>();

                CopyCommandData(NextState as ICommand, false);
            }

Cleanup:

            if (NextState == null)
            {
                NextState = Globals.CreateInstance <IMonsterStartState>();
            }
        }
Beispiel #5
0
        public override void Execute()
        {
            RetCode rc;

            Debug.Assert(DobjArtifact != null && IobjArtifact != null);

            if (!DobjArtifact.IsCarriedByCharacter())
            {
                if (!GetCommandCalled)
                {
                    RedirectToGetCommand <IPutCommand>(DobjArtifact);
                }
                else if (DobjArtifact.DisguisedMonster == null)
                {
                    NextState = Globals.CreateInstance <IStartState>();
                }

                goto Cleanup;
            }

            IobjArtAc = gEngine.EvalContainerType(ContainerType, IobjArtifact.InContainer, IobjArtifact.OnContainer, IobjArtifact.UnderContainer, IobjArtifact.BehindContainer);

            DobjAllContainerArtifactList = DobjArtifact.GetContainedList(containerType: (ContainerType)(-1), recurse: true);

            DobjAllContainerArtifactList.Add(DobjArtifact);

            if (DobjAllContainerArtifactList.Contains(IobjArtifact) || IobjArtAc == null)
            {
                PrintDontFollowYou();

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

            if ((IobjArtifact.IsCarriedByCharacter() && !IobjArtifact.ShouldAddContentsWhenCarried(ContainerType)) || (IobjArtifact.IsWornByCharacter() && !IobjArtifact.ShouldAddContentsWhenWorn(ContainerType)))
            {
                if (IobjArtifact.IsCarriedByCharacter())
                {
                    PrintNotWhileCarryingObj(IobjArtifact);
                }
                else
                {
                    PrintNotWhileWearingObj(IobjArtifact);
                }

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

            if (IobjArtAc == IobjArtifact.InContainer && !IobjArtAc.IsOpen() && !IobjArtifact.ShouldExposeInContentsWhenClosed())
            {
                PrintMustFirstOpen(IobjArtifact);

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

            if ((IobjArtAc == IobjArtifact.InContainer && IobjArtAc.GetKeyUid() == -2) || (IobjArtAc == IobjArtifact.OnContainer && IobjArtifact.InContainer != null && IobjArtifact.InContainer.GetKeyUid() == -2 && IobjArtifact.IsInContainerOpenedFromTop()))
            {
                PrintBrokeIt(IobjArtifact);

                goto Cleanup;
            }

            if (IobjArtAc == IobjArtifact.OnContainer && IobjArtifact.InContainer != null && IobjArtifact.InContainer.IsOpen() && IobjArtifact.IsInContainerOpenedFromTop())
            {
                PrintMustFirstClose(IobjArtifact);

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

            IobjArtifactCount = 0;

            IobjArtifactWeight = 0;

            rc = IobjArtifact.GetContainerInfo(ref _iobjArtifactCount, ref _iobjArtifactWeight, ContainerType, false);

            Debug.Assert(gEngine.IsSuccess(rc));

            if (IobjArtAc.Field3 < 1 || IobjArtAc.Field4 < 1)
            {
                PrintDontNeedTo();

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

            MaxItemsReached = IobjArtifactCount >= IobjArtAc.Field4;

            if ((!MaxItemsReached && IobjArtifactWeight + DobjArtifact.Weight > IobjArtAc.Field3) || !IobjArtifact.ShouldAddContents(DobjArtifact, ContainerType))
            {
                PrintWontFit(DobjArtifact);

                goto Cleanup;
            }

            if (MaxItemsReached || IobjArtifactWeight + DobjArtifact.Weight > IobjArtAc.Field3)
            {
                if (IobjArtAc == IobjArtifact.InContainer)
                {
                    PrintFull(IobjArtifact);
                }
                else
                {
                    PrintOutOfSpace(IobjArtifact);
                }

                goto Cleanup;
            }

            DobjArtifact.SetCarriedByContainer(IobjArtifact, ContainerType);

            if (gGameState.Ls == DobjArtifact.Uid)
            {
                Debug.Assert(DobjArtifact.LightSource != null);

                gEngine.LightOut(DobjArtifact);
            }

            if (ActorMonster.Weapon == DobjArtifact.Uid)
            {
                Debug.Assert(DobjArtifact.GeneralWeapon != null);

                rc = DobjArtifact.RemoveStateDesc(DobjArtifact.GetReadyWeaponDesc());

                Debug.Assert(gEngine.IsSuccess(rc));

                ActorMonster.Weapon = -1;
            }

            gOut.Print("Done.");

            ProcessEvents(EventType.AfterPutArtifact);

            if (GotoCleanup)
            {
                goto Cleanup;
            }

Cleanup:

            if (NextState == null)
            {
                NextState = Globals.CreateInstance <IMonsterStartState>();
            }
        }
Beispiel #6
0
        public override void Execute()
        {
            RetCode rc;

            Debug.Assert(DobjArtifact != null);

            DobjArtAc = DobjArtifact.GetArtifactCategory(ArtTypes, false);

            if (DobjArtAc == null)
            {
                PrintNotWeapon(DobjArtifact);

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

            if (DobjArtAc.Type == ArtifactType.Wearable)
            {
                NextState = Globals.CreateInstance <IWearCommand>();

                CopyCommandData(NextState as ICommand);

                goto Cleanup;
            }

            if (!DobjArtifact.IsReadyableByCharacter())
            {
                PrintNotReadyableWeapon(DobjArtifact);

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

            if (!DobjArtifact.IsCarriedByCharacter())
            {
                if (!GetCommandCalled)
                {
                    RedirectToGetCommand <IReadyCommand>(DobjArtifact);
                }
                else if (DobjArtifact.DisguisedMonster == null)
                {
                    NextState = Globals.CreateInstance <IStartState>();
                }

                goto Cleanup;
            }

            // can't use two-handed weapon while wearing shield

            if (gGameState.Sh > 0 && DobjArtAc.Field5 > 1)
            {
                ShieldArtifact = gADB[gGameState.Sh];

                Debug.Assert(ShieldArtifact != null);

                PrintCantReadyWeaponWithShield(DobjArtifact, ShieldArtifact);

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

            ActorWeapon = gADB[ActorMonster.Weapon];

            if (ActorWeapon != null)
            {
                rc = ActorWeapon.RemoveStateDesc(ActorWeapon.GetReadyWeaponDesc());

                Debug.Assert(gEngine.IsSuccess(rc));
            }

            ActorMonster.Weapon = DobjArtifact.Uid;

            rc = DobjArtifact.AddStateDesc(DobjArtifact.GetReadyWeaponDesc());

            Debug.Assert(gEngine.IsSuccess(rc));

            gOut.Print("{0} readied.", DobjArtifact.GetNoneName(true, false));

            ProcessEvents(EventType.AfterReadyArtifact);

            if (GotoCleanup)
            {
                goto Cleanup;
            }

Cleanup:

            if (NextState == null)
            {
                NextState = Globals.CreateInstance <IMonsterStartState>();
            }
        }
Beispiel #7
0
        public override void Execute()
        {
            RetCode rc;

            Debug.Assert(DobjArtifact != null);

            DobjArtAc = DobjArtifact.LightSource;

            if (DobjArtAc == null)
            {
                if (ActorMonster.IsInRoomLit() || DobjArtifact.IsCarriedByCharacter())
                {
                    PrintCantVerbObj(DobjArtifact);
                }

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

            if (!DobjArtifact.IsUnmovable())
            {
                if (!DobjArtifact.IsCarriedByCharacter())
                {
                    if (!GetCommandCalled)
                    {
                        RedirectToGetCommand <ILightCommand>(DobjArtifact);
                    }
                    else if (DobjArtifact.DisguisedMonster == null)
                    {
                        NextState = Globals.CreateInstance <IStartState>();
                    }

                    goto Cleanup;
                }
            }

            if (DobjArtAc.Field1 == 0)
            {
                PrintWontLight(DobjArtifact);

                NextState = Globals.CreateInstance <IMonsterStartState>();

                goto Cleanup;
            }

            if (gGameState.Ls == DobjArtifact.Uid)
            {
                gOut.Write("{0}Extinguish {1} (Y/N): ", Environment.NewLine, DobjArtifact.GetTheName());

                Globals.Buf.Clear();

                rc = Globals.In.ReadField(Globals.Buf, Constants.BufSize02, null, ' ', '\0', false, null, gEngine.ModifyCharToUpper, gEngine.IsCharYOrN, null);

                Debug.Assert(gEngine.IsSuccess(rc));

                if (Globals.Buf.Length > 0 && Globals.Buf[0] == 'Y')
                {
                    rc = DobjArtifact.RemoveStateDesc(DobjArtifact.GetProvidingLightDesc());

                    Debug.Assert(gEngine.IsSuccess(rc));

                    gGameState.Ls = 0;

                    PrintLightExtinguished(DobjArtifact);
                }

                NextState = Globals.CreateInstance <IMonsterStartState>();

                goto Cleanup;
            }

            if (gGameState.Ls > 0)
            {
                LsArtifact = gADB[gGameState.Ls];

                Debug.Assert(LsArtifact != null && LsArtifact.LightSource != null);

                gEngine.LightOut(LsArtifact);
            }

            rc = DobjArtifact.AddStateDesc(DobjArtifact.GetProvidingLightDesc());

            Debug.Assert(gEngine.IsSuccess(rc));

            gGameState.Ls = DobjArtifact.Uid;

            PrintLightObj(DobjArtifact);

Cleanup:

            if (NextState == null)
            {
                NextState = Globals.CreateInstance <IMonsterStartState>();
            }
        }
Beispiel #8
0
        public override void Execute()
        {
            Debug.Assert(DropAll || DobjArtifact != null);

            if (DobjArtifact != null)
            {
                if (DobjArtifact.IsWornByCharacter())
                {
                    PrintWearingRemoveFirst(DobjArtifact);

                    NextState = Globals.CreateInstance <IStartState>();

                    goto Cleanup;
                }

                if (!DobjArtifact.IsCarriedByCharacter())
                {
                    if (!GetCommandCalled)
                    {
                        if (DobjArtifact.IsCarriedByCharacter(true) && DobjArtifact.IsCarriedByContainer())
                        {
                            RedirectToGetCommand <IDropCommand>(DobjArtifact);
                        }
                        else
                        {
                            NextState = Globals.CreateInstance <IStartState>();
                        }
                    }
                    else if (DobjArtifact.DisguisedMonster == null)
                    {
                        NextState = Globals.CreateInstance <IStartState>();
                    }

                    goto Cleanup;
                }
            }

            ProcessLightSource();

            DroppedArtifactList = DropAll ? ActorMonster.GetCarriedList() : new List <IArtifact>()
            {
                DobjArtifact
            };

            if (DroppedArtifactList.Count <= 0)
            {
                gOut.Print("There's nothing for you to drop.");

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

            foreach (var artifact in DroppedArtifactList)
            {
                ProcessArtifact(artifact);
            }

            gOut.WriteLine();

Cleanup:

            if (NextState == null)
            {
                NextState = Globals.CreateInstance <IMonsterStartState>();
            }
        }
Beispiel #9
0
        public override void Execute()
        {
            RetCode rc;

            Debug.Assert(GoldAmount > 0 || DobjArtifact != null);

            Debug.Assert(IobjMonster != null);

            if (GoldAmount > 0)
            {
                gOut.Print("Give {0} gold piece{1} to {2}.",
                           gEngine.GetStringFromNumber(GoldAmount, false, Globals.Buf),
                           GoldAmount > 1 ? "s" : "",
                           IobjMonster.GetTheName(buf: Globals.Buf01));

                gOut.Write("{0}Are you sure (Y/N): ", Environment.NewLine);

                Globals.Buf.Clear();

                rc = Globals.In.ReadField(Globals.Buf, Constants.BufSize02, null, ' ', '\0', false, null, gEngine.ModifyCharToUpper, gEngine.IsCharYOrN, null);

                Debug.Assert(gEngine.IsSuccess(rc));

                if (Globals.Buf.Length == 0 || Globals.Buf[0] == 'N')
                {
                    NextState = Globals.CreateInstance <IStartState>();

                    goto Cleanup;
                }

                if (gCharacter.HeldGold < GoldAmount)
                {
                    PrintNotEnoughGold();

                    NextState = Globals.CreateInstance <IStartState>();

                    goto Cleanup;
                }

                ProcessEvents(EventType.BeforeTakePlayerGold);

                if (GotoCleanup)
                {
                    goto Cleanup;
                }

                gOut.Print("{0} take{1} the money.",
                           IobjMonster.GetTheName(true),
                           IobjMonster.EvalPlural("s", ""));

                gCharacter.HeldGold -= GoldAmount;

                if (Globals.IsRulesetVersion(5, 25))
                {
                    IobjMonster.CalculateGiftFriendliness(GoldAmount, false);

                    IobjMonster.ResolveReaction(gCharacter);
                }
                else
                {
                    if (IobjMonster.Reaction == Friendliness.Neutral && GoldAmount > 4999)
                    {
                        IobjMonster.Friendliness = (Friendliness)200;

                        IobjMonster.Reaction = Friendliness.Friend;

                        gEngine.MonsterEmotes(IobjMonster);

                        gOut.WriteLine();
                    }
                }

                goto Cleanup;
            }

            if (DobjArtifact.IsWornByCharacter())
            {
                PrintWearingRemoveFirst(DobjArtifact);

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

            if (!DobjArtifact.IsCarriedByCharacter())
            {
                if (!GetCommandCalled)
                {
                    RedirectToGetCommand <IGiveCommand>(DobjArtifact);
                }
                else if (DobjArtifact.DisguisedMonster == null)
                {
                    NextState = Globals.CreateInstance <IStartState>();
                }

                goto Cleanup;
            }

            if (IobjMonster.ShouldRefuseToAcceptGift(DobjArtifact))
            {
                gEngine.MonsterEmotes(IobjMonster);

                gOut.WriteLine();

                goto Cleanup;
            }

            DobjArtifactCount = 0;

            DobjArtifactWeight = DobjArtifact.Weight;

            if (DobjArtifact.GeneralContainer != null)
            {
                rc = DobjArtifact.GetContainerInfo(ref _dobjArtifactCount, ref _dobjArtifactWeight, ContainerType.In, true);

                Debug.Assert(gEngine.IsSuccess(rc));

                rc = DobjArtifact.GetContainerInfo(ref _dobjArtifactCount, ref _dobjArtifactWeight, ContainerType.On, true);

                Debug.Assert(gEngine.IsSuccess(rc));
            }

            if (gEngine.EnforceMonsterWeightLimits)
            {
                IobjMonsterInventoryWeight = 0;

                rc = IobjMonster.GetFullInventoryWeight(ref _iobjMonsterInventoryWeight, recurse: true);

                Debug.Assert(gEngine.IsSuccess(rc));

                if (DobjArtifactWeight > IobjMonster.GetWeightCarryableGronds() || DobjArtifactWeight + IobjMonsterInventoryWeight > IobjMonster.GetWeightCarryableGronds() * IobjMonster.CurrGroupCount)
                {
                    PrintTooHeavy(DobjArtifact);

                    goto Cleanup;
                }
            }

            ProcessEvents(EventType.AfterEnforceMonsterWeightLimitsCheck);

            if (GotoCleanup)
            {
                goto Cleanup;
            }

            if (DobjArtifact.DeadBody != null && IobjMonster.ShouldRefuseToAcceptDeadBody(DobjArtifact))
            {
                PrintPolitelyRefuses(IobjMonster);

                goto Cleanup;
            }

            if (gGameState.Ls == DobjArtifact.Uid)
            {
                Debug.Assert(DobjArtifact.LightSource != null);

                gEngine.LightOut(DobjArtifact);
            }

            if (ActorMonster.Weapon == DobjArtifact.Uid)
            {
                Debug.Assert(DobjArtifact.GeneralWeapon != null);

                rc = DobjArtifact.RemoveStateDesc(DobjArtifact.GetReadyWeaponDesc());

                Debug.Assert(gEngine.IsSuccess(rc));

                ActorMonster.Weapon = -1;
            }

            ProcessEvents(EventType.AfterGiveReadiedWeaponCheck);

            if (GotoCleanup)
            {
                goto Cleanup;
            }

            PrintGiveObjToActor(DobjArtifact, IobjMonster);

            DobjArtAc = DobjArtifact.GetArtifactCategory(new ArtifactType[] { ArtifactType.Drinkable, ArtifactType.Edible });

            if (Globals.IsRulesetVersion(5, 25) || DobjArtAc == null || DobjArtAc.Field2 <= 0)
            {
                DobjArtifact.SetCarriedByMonster(IobjMonster);

                if (Globals.IsRulesetVersion(5, 25))
                {
                    IobjMonster.CalculateGiftFriendliness(DobjArtifact.Value, true);

                    IobjMonster.ResolveReaction(gCharacter);
                }
                else
                {
                    if (IobjMonster.Reaction == Friendliness.Neutral)
                    {
                        IobjMonster.Friendliness = (Friendliness)200;

                        IobjMonster.Reaction = Friendliness.Friend;

                        gEngine.MonsterEmotes(IobjMonster);

                        gOut.WriteLine();
                    }
                }

                goto Cleanup;
            }

            IobjMonsterName = IobjMonster.EvalPlural(IobjMonster.GetTheName(true), IobjMonster.GetArticleName(true, true, false, true, Globals.Buf01));

            Globals.Buf01.Clear();

            if (!DobjArtAc.IsOpen())
            {
                Globals.Buf01.SetFormat(" opens {0}", DobjArtifact.GetTheName());

                DobjArtAc.SetOpen(true);
            }

            if (DobjArtAc.Field2 != Constants.InfiniteDrinkableEdible)
            {
                DobjArtAc.Field2--;
            }

            if (DobjArtAc.Field2 > 0)
            {
                Globals.Buf.SetPrint("{0}{1}{2} takes a {3} and hands {4} back.",
                                     IobjMonsterName,
                                     Globals.Buf01,
                                     Globals.Buf01.Length > 0 ? "," : "",
                                     DobjArtAc.Type == ArtifactType.Edible ? "bite" : "drink",
                                     DobjArtifact.EvalPlural("it", "them"));
            }
            else
            {
                DobjArtifact.Value = 0;

                if (DobjArtAc.Type == ArtifactType.Edible)
                {
                    DobjArtifact.SetInLimbo();

                    Globals.Buf.SetPrint("{0}{1}{2} eats {3} all.",
                                         IobjMonsterName,
                                         Globals.Buf01,
                                         Globals.Buf01.Length > 0 ? " and" : "",
                                         DobjArtifact.EvalPlural("it", "them"));
                }
                else
                {
                    rc = DobjArtifact.AddStateDesc(DobjArtifact.GetEmptyDesc());

                    Debug.Assert(gEngine.IsSuccess(rc));

                    Globals.Buf.SetPrint("{0}{1}{2} drinks {3} all and hands {4} back.",
                                         IobjMonsterName,
                                         Globals.Buf01,
                                         Globals.Buf01.Length > 0 ? "," : "",
                                         DobjArtifact.EvalPlural("it", "them"),
                                         DobjArtifact.EvalPlural("it", "them"));
                }
            }

            gOut.Write("{0}", Globals.Buf);

            if (DobjArtAc.Field1 == 0)
            {
                goto Cleanup;
            }

            IobjMonster.DmgTaken -= DobjArtAc.Field1;

            if (IobjMonster.DmgTaken < 0)
            {
                IobjMonster.DmgTaken = 0;
            }

            Globals.Buf.SetFormat("{0}{1} is ",
                                  Environment.NewLine,
                                  IobjMonster.GetTheName(true, true, false, true, Globals.Buf01));

            IobjMonster.AddHealthStatus(Globals.Buf);

            gOut.Write("{0}", Globals.Buf);

            if (IobjMonster.IsDead())
            {
                gEngine.MonsterDies(ActorMonster, IobjMonster);
            }

Cleanup:

            if (NextState == null)
            {
                NextState = Globals.CreateInstance <IMonsterStartState>();
            }
        }
Beispiel #10
0
        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>();
            }
        }
Beispiel #11
0
        public override void Execute()
        {
            Debug.Assert(DobjArtifact != null);

            if (IobjArtifact != null)
            {
                if (!GetCommandCalled)
                {
                    RedirectToGetCommand <IRemoveCommand>(DobjArtifact, false);

                    goto Cleanup;
                }

                if (!DobjArtifact.IsCarriedByCharacter())
                {
                    if (DobjArtifact.DisguisedMonster == null)
                    {
                        NextState = Globals.CreateInstance <IStartState>();
                    }

                    goto Cleanup;
                }

                if (ActorMonster.Weapon <= 0 && DobjArtifact.IsReadyableByCharacter() && NextState == null)
                {
                    NextState = Globals.CreateInstance <IReadyCommand>();

                    CopyCommandData(NextState as ICommand, false);

                    goto Cleanup;
                }

                goto Cleanup;
            }

            ArmorArtifact = gADB[gGameState.Ar];

            ShieldArtifact = gADB[gGameState.Sh];

            ArmorArtifactAc = ArmorArtifact != null ? ArmorArtifact.Wearable : null;

            ShieldArtifactAc = ShieldArtifact != null ? ShieldArtifact.Wearable : null;

            if (DobjArtifact.Uid == gGameState.Sh)
            {
                ActorMonster.Armor = ArmorArtifactAc != null ? (ArmorArtifactAc.Field1 / 2) + ((ArmorArtifactAc.Field1 / 2) >= 3 ? 2 : 0) : 0;

                gGameState.Sh = 0;
            }

            if (DobjArtifact.Uid == gGameState.Ar)
            {
                ActorMonster.Armor = ShieldArtifactAc != null ? ShieldArtifactAc.Field1 : 0;

                gGameState.Ar = 0;
            }

            DobjArtifact.SetCarriedByCharacter();

            PrintRemoved(DobjArtifact);

            ProcessEvents(EventType.AfterRemoveWornArtifact);

            if (GotoCleanup)
            {
                goto Cleanup;
            }

Cleanup:

            if (NextState == null)
            {
                NextState = Globals.CreateInstance <IMonsterStartState>();
            }
        }
Beispiel #12
0
        public override void Execute()
        {
            Debug.Assert(DobjArtifact != null);

            DobjArtAc = DobjArtifact.Wearable;

            if (DobjArtAc == null)
            {
                PrintCantVerbObj(DobjArtifact);

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

            if (DobjArtifact.IsWornByCharacter())
            {
                gOut.Print("You're already wearing {0}!", DobjArtifact.EvalPlural("it", "them"));

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

            if (!DobjArtifact.IsCarriedByCharacter())
            {
                if (!GetCommandCalled)
                {
                    RedirectToGetCommand <IWearCommand>(DobjArtifact);
                }
                else if (DobjArtifact.DisguisedMonster == null)
                {
                    NextState = Globals.CreateInstance <IStartState>();
                }

                goto Cleanup;
            }

            if (DobjArtAc.Field1 > 0)
            {
                ArmorArtifact = gADB[gGameState.Ar];

                ShieldArtifact = gADB[gGameState.Sh];

                ArmorArtifactAc = ArmorArtifact != null ? ArmorArtifact.Wearable : null;

                ShieldArtifactAc = ShieldArtifact != null ? ShieldArtifact.Wearable : null;

                if (DobjArtAc.Field1 > 1)
                {
                    if (DobjArtAc.Field1 > 14)
                    {
                        DobjArtAc.Field1 = 14;
                    }

                    if (ArmorArtifactAc != null)
                    {
                        gOut.Print("You're already wearing armor!");

                        NextState = Globals.CreateInstance <IStartState>();

                        goto Cleanup;
                    }

                    gGameState.Ar = DobjArtifact.Uid;

                    ActorMonster.Armor = (DobjArtAc.Field1 / 2) + ((DobjArtAc.Field1 / 2) >= 3 ? 2 : 0) + (ShieldArtifactAc != null ? ShieldArtifactAc.Field1 : 0);
                }
                else
                {
                    if (ShieldArtifactAc != null)
                    {
                        gOut.Print("You're already wearing a shield!");

                        NextState = Globals.CreateInstance <IStartState>();

                        goto Cleanup;
                    }

                    // can't wear shield while using two-handed weapon

                    WeaponArtifact = ActorMonster.Weapon > 0 ? gADB[ActorMonster.Weapon] : null;

                    WeaponArtifactAc = WeaponArtifact != null ? WeaponArtifact.GeneralWeapon : null;

                    if (WeaponArtifactAc != null && WeaponArtifactAc.Field5 > 1)
                    {
                        PrintCantWearShieldWithWeapon(DobjArtifact, WeaponArtifact);

                        NextState = Globals.CreateInstance <IStartState>();

                        goto Cleanup;
                    }

                    gGameState.Sh = DobjArtifact.Uid;

                    ActorMonster.Armor = (ArmorArtifactAc != null ? (ArmorArtifactAc.Field1 / 2) + ((ArmorArtifactAc.Field1 / 2) >= 3 ? 2 : 0) : 0) + DobjArtAc.Field1;
                }
            }

            DobjArtifact.SetWornByCharacter();

            PrintWorn(DobjArtifact);

            ProcessEvents(EventType.AfterWearArtifact);

            if (GotoCleanup)
            {
                goto Cleanup;
            }

Cleanup:

            if (NextState == null)
            {
                NextState = Globals.CreateInstance <IMonsterStartState>();
            }
        }
Beispiel #13
0
        public override void Execute()
        {
            RetCode rc;

            Debug.Assert(DobjArtifact != null || DobjMonster != null);

            if (!ActorRoom.IsLit())
            {
                Debug.Assert(DobjMonster != null && DobjMonster.IsCharacterMonster());
            }

            if (DobjArtifact != null)
            {
                DobjArtAc = DobjArtifact.InContainer;

                if (DobjArtAc == null)
                {
                    DobjArtAc = DobjArtifact.OnContainer;
                }

                if (DobjArtAc == null && AllowExtendedContainers)
                {
                    DobjArtAc = DobjArtifact.UnderContainer;
                }

                if (DobjArtAc == null && AllowExtendedContainers)
                {
                    DobjArtAc = DobjArtifact.BehindContainer;
                }

                if (DobjArtAc == null)
                {
                    PrintCantVerbObj(DobjArtifact);

                    NextState = Globals.CreateInstance <IStartState>();

                    goto Cleanup;
                }

                DobjArtContainerType = gEngine.GetContainerType(DobjArtAc.Type);

                if (DobjArtifact.IsEmbeddedInRoom(ActorRoom))
                {
                    DobjArtifact.SetInRoom(ActorRoom);
                }

                if (DobjArtAc == DobjArtifact.InContainer && !DobjArtAc.IsOpen() && !DobjArtifact.ShouldExposeInContentsWhenClosed())
                {
                    PrintMustFirstOpen(DobjArtifact);

                    NextState = Globals.CreateInstance <IStartState>();

                    goto Cleanup;
                }

                DobjArtContainedArtifactList = DobjArtifact.GetContainedList(containerType: DobjArtContainerType);

                ShowCharOwned = !DobjArtifact.IsCarriedByCharacter() && !DobjArtifact.IsWornByCharacter();

                if (DobjArtContainedArtifactList.Count > 0)
                {
                    Globals.Buf.SetFormat("{0}{1} {2} you see ",
                                          Environment.NewLine,
                                          gEngine.EvalContainerType(DobjArtContainerType, "Inside", "On", "Under", "Behind"),
                                          DobjArtifact.GetTheName(false, ShowCharOwned, false, false, Globals.Buf01));

                    rc = gEngine.GetRecordNameList(DobjArtContainedArtifactList.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(DobjArtContainerType, "inside", "on", "under", "behind"),
                                          DobjArtifact.GetTheName(false, ShowCharOwned, false, false, Globals.Buf01));
                }

                Globals.Buf.AppendFormat(".{0}", Environment.NewLine);

                gOut.Write("{0}", Globals.Buf);

                goto Cleanup;
            }

            IsCharMonster = DobjMonster.IsCharacterMonster();

            if (!IsCharMonster && DobjMonster.Reaction < Friendliness.Friend)
            {
                gEngine.MonsterEmotes(DobjMonster);

                gOut.WriteLine();

                goto Cleanup;
            }

            HasWornInventory = DobjMonster.HasWornInventory();

            if (HasWornInventory)
            {
                DobjMonsterWornArtifactList = DobjMonster.GetWornList();

                if (DobjMonsterWornArtifactList.Count > 0)
                {
                    Globals.Buf.SetFormat("{0}{1} {2} {3}",
                                          Environment.NewLine,
                                          IsCharMonster ? "You" : DobjMonster.EvalPlural(DobjMonster.GetTheName(true, true, false, true, Globals.Buf01), "They"),
                                          IsCharMonster ? "are" : DobjMonster.EvalPlural("is", "are"),
                                          IsCharMonster ? "wearing " : DobjMonster.EvalPlural("wearing ", "wearing among them "));

                    rc = gEngine.GetRecordNameList(DobjMonsterWornArtifactList.Cast <IGameBase>().ToList(), ArticleType.A, IsCharMonster ? false : true, IsCharMonster ? StateDescDisplayCode.AllStateDescs : StateDescDisplayCode.SideNotesOnly, IsCharMonster ? true : false, false, Globals.Buf);

                    Debug.Assert(gEngine.IsSuccess(rc));

                    Globals.Buf.AppendFormat(".{0}", Environment.NewLine);

                    gOut.Write("{0}", Globals.Buf);
                }
            }

            HasCarriedInventory = DobjMonster.HasCarriedInventory();

            if (HasCarriedInventory)
            {
                DobjMonsterCarriedArtifactList = DobjMonster.GetCarriedList();

                if (IsCharMonster)
                {
                    // use total debt for characters with no assets; otherwise use HeldGold (which may be debt or asset)

                    TotalGold = gCharacter.HeldGold < 0 && gCharacter.BankGold < 0 ? gCharacter.HeldGold + gCharacter.BankGold : gCharacter.HeldGold;

                    if (TotalGold != 0)
                    {
                        GoldArtifact = Globals.CreateInstance <IArtifact>(x =>
                        {
                            x.Name = string.Format("{0}{1} gold piece{2}",
                                                   TotalGold < 0 ? "a debt of " : "",
                                                   gEngine.GetStringFromNumber(Math.Abs(TotalGold), false, Globals.Buf),
                                                   Math.Abs(TotalGold) != 1 ? "s" : "");
                        });

                        DobjMonsterCarriedArtifactList.Add(GoldArtifact);
                    }
                }

                Globals.Buf.SetFormat("{0}{1} {2} {3}",
                                      Environment.NewLine,
                                      IsCharMonster ? "You" : DobjMonster.EvalPlural(DobjMonster.GetTheName(true, true, false, true, Globals.Buf01), "They"),
                                      IsCharMonster ? "are" : DobjMonster.EvalPlural("is", "are"),
                                      DobjMonsterCarriedArtifactList.Count == 0 ? "" :
                                      IsCharMonster ? "carrying " : DobjMonster.EvalPlural("carrying ", "carrying among them "));

                if (DobjMonsterCarriedArtifactList.Count > 0)
                {
                    rc = gEngine.GetRecordNameList(DobjMonsterCarriedArtifactList.Cast <IGameBase>().ToList(), ArticleType.A, IsCharMonster ? false : true, IsCharMonster ? StateDescDisplayCode.AllStateDescs : StateDescDisplayCode.SideNotesOnly, IsCharMonster ? true : false, false, Globals.Buf);

                    Debug.Assert(gEngine.IsSuccess(rc));
                }
                else
                {
                    Globals.Buf.Append("empty handed");
                }

                Globals.Buf.AppendFormat(".{0}", Environment.NewLine);

                gOut.Write("{0}", Globals.Buf);
            }

            ShouldShowHealthStatusWhenInventoried = DobjMonster.ShouldShowHealthStatusWhenInventoried();

            if (ShouldShowHealthStatusWhenInventoried)
            {
                IsUninjuredGroup = DobjMonster.CurrGroupCount > 1 && DobjMonster.DmgTaken == 0;

                Globals.Buf.SetFormat("{0}{1} {2} ",
                                      Environment.NewLine,
                                      IsCharMonster ? "You" :
                                      IsUninjuredGroup ? "They" :
                                      DobjMonster.GetTheName(true, true, false, true, Globals.Buf01),
                                      IsCharMonster || IsUninjuredGroup ? "are" : "is");

                DobjMonster.AddHealthStatus(Globals.Buf);

                gOut.Write("{0}", Globals.Buf);
            }

            if (GoldArtifact != null)
            {
                GoldArtifact.Dispose();

                GoldArtifact = null;
            }

            if (!HasWornInventory && !HasCarriedInventory && !ShouldShowHealthStatusWhenInventoried)
            {
                PrintCantVerbObj(DobjMonster);

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

Cleanup:

            if (NextState == null)
            {
                NextState = Globals.CreateInstance <IMonsterStartState>();
            }
        }