Ejemplo n.º 1
0
        public virtual void ProcessArtifact(IArtifact artifact, IArtifactCategory ac, ref bool nlFlag)
        {
            RetCode rc;

            Debug.Assert(artifact != null);

            Debug.Assert(ac != null);

            if (ac.Type == ArtifactType.DisguisedMonster)
            {
                ProcessAction(() => gEngine.RevealDisguisedMonster(ActorRoom, artifact), ref nlFlag);
            }
            else if (artifact.Weight > 900)
            {
                ProcessAction(() => PrintDontBeAbsurd(), ref nlFlag);
            }
            else if (artifact.IsUnmovable01())
            {
                ProcessAction(() => PrintCantVerbThat(artifact), ref nlFlag);
            }
            else
            {
                DobjArtifactCount = 0;

                DobjArtifactWeight = artifact.Weight;

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

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

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

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

                ActorMonsterInventoryWeight = 0;

                rc = ActorMonster.GetFullInventoryWeight(ref _actorMonsterInventoryWeight, recurse: true);

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

                if (ac.Type == ArtifactType.DeadBody && ac.Field1 != 1)
                {
                    ProcessAction(() => PrintBestLeftAlone(artifact), ref nlFlag);
                }
                else if (!OmitWeightCheck && (DobjArtifactWeight + ActorMonsterInventoryWeight > ActorMonster.GetWeightCarryableGronds()))
                {
                    ProcessAction(() => PrintTooHeavy(artifact), ref nlFlag);
                }
                else if (ac.Type == ArtifactType.BoundMonster)
                {
                    ProcessAction(() => PrintMustBeFreed(artifact), ref nlFlag);
                }
                else
                {
                    WeaponAffinityMonster = gEngine.GetMonsterList(m => m.IsInRoom(ActorRoom) && m.Weapon == -artifact.Uid - 1 && m != ActorMonster).FirstOrDefault();

                    if (WeaponAffinityMonster != null)
                    {
                        ProcessAction(() => PrintObjBelongsToActor(artifact, WeaponAffinityMonster), ref nlFlag);
                    }
                    else
                    {
                        IsCarriedByContainer = artifact.IsCarriedByContainer();

                        artifact.SetCarriedByCharacter();

                        if (NextState is IRequestCommand)
                        {
                            PrintReceived(artifact);
                        }
                        else if (NextState is IRemoveCommand || IsCarriedByContainer)
                        {
                            PrintRetrieved(artifact);
                        }
                        else
                        {
                            PrintTaken(artifact);
                        }

                        nlFlag = true;
                    }
                }
            }
        }