Example #1
0
        public override void FinishParsingGetCommand()
        {
            ParseName();

            if (ObjData.Name.Equals("all", StringComparison.OrdinalIgnoreCase))
            {
                if (gGameState.GetNBTL(Friendliness.Enemy) > 0)
                {
                    NextCommand.PrintEnemiesNearby();

                    NextState = Globals.CreateInstance <IStartState>();
                }
                else
                {
                    NextCommand.Cast <IGetCommand>().GetAll = true;
                }
            }
            else if (ActorRoom.Type == RoomType.Indoors && ObjData.Name.IndexOf("torch", StringComparison.OrdinalIgnoreCase) >= 0)
            {
                if (gGameState.GetNBTL(Friendliness.Enemy) > 0)
                {
                    NextCommand.PrintEnemiesNearby();

                    NextState = Globals.CreateInstance <IStartState>();
                }
                else
                {
                    gOut.Print("They are bolted firmly to the walls.");

                    NextState = Globals.CreateInstance <IMonsterStartState>();
                }
            }
            else
            {
                ObjData.RecordWhereClauseList = new List <Func <IGameBase, bool> >()
                {
                    r => r is IArtifact a && a.IsInRoom(ActorRoom),
                    r => r is IArtifact a && a.IsEmbeddedInRoom(ActorRoom),
                    r => r is IArtifact a && (a.IsCarriedByContainerContainerTypeExposedToCharacter(gEngine.ExposeContainersRecursively) || a.IsCarriedByContainerContainerTypeExposedToRoom(ActorRoom, gEngine.ExposeContainersRecursively))
                };

                ObjData.RecordNotFoundFunc = NextCommand.PrintCantVerbThat;

                ResolveRecord(false);
            }
        }
    }
Example #2
0
        public override void CheckPlayerCommand(bool afterFinishParsing)
        {
            Debug.Assert(NextCommand != null);

            if (afterFinishParsing)
            {
                // Restrict various commands while paralyzed

                if (!(NextCommand is ISmileCommand || (NextCommand.Type == CommandType.Miscellaneous && !(NextCommand is ISpeedCommand || NextCommand is IPowerCommand))) && gGameState.ParalyzedTargets.ContainsKey(gGameState.Cm))
                {
                    gOut.Print("You can't do that while paralyzed!");

                    NextState = Globals.CreateInstance <IStartState>();
                }

                // Restrict GiveCommand and RequestCommand when targeting paralyzed Monster

                else if ((NextCommand is IGiveCommand || NextCommand is IRequestCommand) && IobjMonster != null && gGameState.ParalyzedTargets.ContainsKey(IobjMonster.Uid))
                {
                    gOut.Print("You can't do that while {0} {1} paralyzed!", IobjMonster.GetTheName(), IobjMonster.EvalPlural("is", "are"));

                    NextState = Globals.CreateInstance <IStartState>();
                }

                // Restrict SearchCommand while enemies are present

                else if (NextCommand is ISearchCommand && gGameState.GetNBTL(Friendliness.Enemy) > 0)
                {
                    NextCommand.PrintEnemiesNearby();

                    NextState = Globals.CreateInstance <IStartState>();
                }

                // Restrict Commands in the graveyard at night or in heavy fog

                else if ((NextCommand is IReadCommand || NextCommand is ISearchCommand) && gActorRoom(this).IsDimLightRoomWithoutGlowingMonsters() && gGameState.Ls <= 0)
                {
                    gOut.Print("You'll need a bit more light for that!");

                    NextState = Globals.CreateInstance <IMonsterStartState>();
                }
                else
                {
                    var waterWeirdMonster = gMDB[38];

                    Debug.Assert(waterWeirdMonster != null);

                    // Large fountain and water weird

                    if (DobjArtifact != null && DobjArtifact.Uid != 24 && DobjArtifact.Uid != 40 && IobjArtifact != null && IobjArtifact.Uid == 24)
                    {
                        if (waterWeirdMonster.IsInRoom(ActorRoom))
                        {
                            gOut.Print("{0} won't let you get close enough to do that!", waterWeirdMonster.GetTheName(true));

                            NextState = Globals.CreateInstance <IMonsterStartState>();
                        }
                        else if (!gGameState.WaterWeirdKilled)
                        {
                            gEngine.PrintEffectDesc(100);

                            waterWeirdMonster.SetInRoom(ActorRoom);

                            NextState = Globals.CreateInstance <IStartState>();
                        }
                        else
                        {
                            base.CheckPlayerCommand(afterFinishParsing);
                        }
                    }
                    else
                    {
                        base.CheckPlayerCommand(afterFinishParsing);
                    }
                }
            }
            else
            {
                base.CheckPlayerCommand(afterFinishParsing);
            }
        }