示例#1
0
 public DeSerializationResult(string id, bool success, IArtifact result, IEnumerable<string> warnings)
 {
     this.id = id;
     this.warnings = warnings;
     this.result = result;
     this.success = success;
 }
示例#2
0
        public TestArtifactInfo(IArtifact artifact) {
            var attr = artifact.GetAttribute<TestAttribute>();
            this.IsValid = true;
            this.Artifact = artifact;
            artifact.Changed += (sender, eventArgs) => {
                lock (this)
                {
                    if (eventArgs.ChangeType == ArtifactChangeTypes.Deleted)
                    {
                        this.IsValid = false;
                        this._testClassInfos = null;
                    }
                    else
                    {
                        this._testClassInfos = null;
                    }
                }
            };

            if (attr != null) {
                this.Description = attr.Description;



            }
        }
示例#3
0
 bool InternalAddReference(IArtifact artifact) {
     var refc = new CompileReference(artifact);
     var existed = _references.Find(p => p.MetadataReference.Equals(refc));
     if (existed != null) return false;
     _references.Add(refc);
     return true;
 }
示例#4
0
        public virtual void PrintWontFit(IArtifact artifact)
        {
            Debug.Assert(artifact != null);

            gOut.Print("{0} won't fit.", artifact.EvalPlural("It", "They"));
        }
示例#5
0
        public virtual void PrintDropped(IArtifact artifact)
        {
            Debug.Assert(artifact != null);

            gOut.Write("{0}{1} dropped.", Environment.NewLine, artifact.GetNoneName(true, false));
        }
示例#6
0
        public virtual void PrintMustFirstClose(IArtifact artifact)
        {
            Debug.Assert(artifact != null);

            gOut.Print("You must first close {0}.", artifact.EvalPlural("it", "them"));
        }
示例#7
0
        public virtual void PrintTooHeavy(IArtifact artifact)
        {
            Debug.Assert(artifact != null);

            gOut.Print("{0} {1} too heavy.", artifact.GetTheName(true), artifact.EvalPlural("is", "are"));
        }
示例#8
0
 public static string GetText(this IArtifact artifact, ITextSnapshot snapshot)
 {
     return(snapshot.GetText(artifact.InnerRange.Start, artifact.InnerRange.Length));
 }
示例#9
0
 public override bool ShouldRefuseToAcceptGift(IArtifact artifact)
 {
     return(false);
 }
示例#10
0
 public bool Compare(IArtifact art1, IArtifact art2, ICollection <Difference> differences = null)
 {
     throw new NotImplementedException();
 }
示例#11
0
 public ArtifactDeployState ProcessInit(IArtifact art, IDeployContext context)
 {
     throw new NotImplementedException();
 }
示例#12
0
 public virtual void PrintObjBlocksTheWay(IArtifact artifact)
 {
     StateImpl.PrintObjBlocksTheWay(artifact);
 }
示例#13
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>();
            }
        }
示例#14
0
 public virtual bool ShouldRefuseToAcceptGift01(IArtifact artifact)
 {
     return(base.ShouldRefuseToAcceptGift(artifact));
 }
示例#15
0
 public void deleteArtifact(IArtifact artifact)
 {
     artifacts.Remove(artifact);
 }
示例#16
0
 public void Add( IArtifact artifact )
 {
     if( !this.artifacts.ContainsKey( artifact.Id ) )
         this.artifacts.Add( artifact.Id, artifact );
 }
 public void ReturnItemFromUser(IUser user, IArtifact item)
 {
     user.Account.ReturnItem(item, item.Price * (user.UserRole.ChargeRate / 100));
 }
示例#18
0
        public virtual void PrintBestLeftAlone(IArtifact artifact)
        {
            Debug.Assert(artifact != null);

            gOut.Print("{0} {1} best if left alone.", artifact.GetTheName(true), artifact.EvalPlural("is", "are"));
        }
示例#19
0
        public virtual bool TryCreateArtifactFromId(ArtifactType artifactType, string id, out IArtifact artifact)
        {
            if (null == artifactType)
            {
                throw new ArgumentNullException("artifactType");
            }

            if (string.IsNullOrEmpty(id))
            {
                throw new ArgumentNullException("id");
            }

            artifact = null;
            return(CanHandleArtifactType(artifactType));
        }
示例#20
0
        public virtual void PrintMustBeFreed(IArtifact artifact)
        {
            Debug.Assert(artifact != null);

            gOut.Print("{0} must be freed.", artifact.GetTheName(true));
        }
        public override bool TryCreateArtifactFromId(ArtifactType artifactType, string id, out IArtifact artifact)
        {
            if (!base.TryCreateArtifactFromId(artifactType, id, out artifact))
            {
                return(false);
            }

            artifact = new Toolkit.Linking.Artifact(UriFromId(id), m_handledArtifactType);
            return(true);
        }
示例#22
0
        public virtual void PrintClosed(IArtifact artifact)
        {
            Debug.Assert(artifact != null);

            gOut.Print("{0} closed.", artifact.GetNoneName(true, false));
        }
示例#23
0
        public override void PlayerExecute()
        {
            Debug.Assert(GetAll || gDobjArtifact != null);

            if (GetAll)
            {
                // screen out all weapons in the room which have monsters present with affinities to those weapons

                ArtifactList = gActorRoom.GetTakeableList().Where(a => gEngine.GetMonsterList(m => m.IsInRoom(gActorRoom) && m.Weapon == -a.Uid - 1 && m != gActorMonster).FirstOrDefault() == null).ToList();
            }
            else
            {
                ArtifactList = new List <IArtifact>()
                {
                    gDobjArtifact
                };
            }

            if (ArtifactList.Count > 0)
            {
                var artTypes = new ArtifactType[] { ArtifactType.DisguisedMonster, ArtifactType.DeadBody, ArtifactType.BoundMonster, ArtifactType.Weapon, ArtifactType.MagicWeapon };

                var nlFlag = false;

                IArtifact wpnArtifact = null;

                foreach (var artifact in ArtifactList)
                {
                    var ac = artifact.GetArtifactCategory(artTypes, false);

                    if (ac == null)
                    {
                        ac = artifact.GetCategories(0);
                    }

                    Debug.Assert(ac != null);

                    OmitWeightCheck = artifact.IsCarriedByCharacter(true);

                    ProcessArtifact(artifact, ac, ref nlFlag);

                    if (artifact.IsCarriedByCharacter())
                    {
                        // when a weapon is picked up all monster affinities to that weapon are broken

                        var fumbleMonsters = gEngine.GetMonsterList(m => m.Weapon == -artifact.Uid - 1 && m != gActorMonster);

                        foreach (var monster in fumbleMonsters)
                        {
                            monster.Weapon = -1;
                        }

                        var ac01 = artifact.GeneralWeapon;

                        if (artifact.IsReadyableByCharacter() && (wpnArtifact == null || gEngine.WeaponPowerCompare(artifact, wpnArtifact) > 0) && (!GetAll || ArtifactList.Count == 1 || gGameState.Sh < 1 || ac01.Field5 < 2))
                        {
                            wpnArtifact = artifact;
                        }
                    }
                }

                if (nlFlag)
                {
                    gOut.WriteLine();

                    nlFlag = false;
                }

                if (gActorRoom.IsLit())
                {
                    if (!gEngine.AutoDisplayUnseenArtifactDescs && !GetAll && gDobjArtifact.IsCarriedByCharacter() && !gDobjArtifact.Seen)
                    {
                        Globals.Buf.Clear();

                        var rc = gDobjArtifact.BuildPrintedFullDesc(Globals.Buf, false);

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

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

                        gDobjArtifact.Seen = true;
                    }
                }

                if (gActorMonster.Weapon <= 0 && wpnArtifact != null && NextState == null)
                {
                    var command = Globals.CreateInstance <IReadyCommand>();

                    CopyCommandData(command);

                    command.Dobj = wpnArtifact;

                    NextState = command;
                }
            }
            else
            {
                gOut.Print("There's nothing for you to get.");

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

Cleanup:

            if (NextState == null)
            {
                NextState = Globals.CreateInstance <IMonsterStartState>();
            }
        }
示例#24
0
        public virtual void PrintAlreadyOpen(IArtifact artifact)
        {
            Debug.Assert(artifact != null);

            gOut.Print("{0} already open.", artifact.EvalPlural("It's", "They're"));
        }
示例#25
0
 public override bool ShouldShowUnseenArtifacts(IRoom room, IArtifact artifact)
 {
     return(false);
 }
示例#26
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(gActorRoom, artifact), ref nlFlag);
            }
            else if (artifact.Weight > 900)
            {
                ProcessAction(() => PrintDontBeAbsurd(), ref nlFlag);
            }
            else if (artifact.IsUnmovable01())
            {
                ProcessAction(() => PrintCantVerbThat(artifact), ref nlFlag);
            }
            else
            {
                var count = 0L;

                var weight = artifact.Weight;

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

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

                    rc = artifact.GetContainerInfo(ref count, ref weight, ContainerType.On, true);

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

                var charWeight = 0L;

                rc = gActorMonster.GetFullInventoryWeight(ref charWeight, recurse: true);

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

                if (ac.Type == ArtifactType.DeadBody && ac.Field1 != 1)
                {
                    ProcessAction(() => PrintBestLeftAlone(artifact), ref nlFlag);
                }
                else if (!OmitWeightCheck && (weight + charWeight > gActorMonster.GetWeightCarryableGronds()))
                {
                    ProcessAction(() => PrintTooHeavy(artifact), ref nlFlag);
                }
                else if (ac.Type == ArtifactType.BoundMonster)
                {
                    ProcessAction(() => PrintMustBeFreed(artifact), ref nlFlag);
                }
                else
                {
                    var monster = gEngine.GetMonsterList(m => m.IsInRoom(gActorRoom) && m.Weapon == -artifact.Uid - 1 && m != gActorMonster).FirstOrDefault();

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

                        artifact.SetCarriedByCharacter();

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

                        nlFlag = true;
                    }
                }
            }
        }
示例#27
0
        public virtual void DecrementLightTurnCounter(IArtifact artifact, IArtifactCategory ac)
        {
            Debug.Assert(artifact != null && ac != null);

            ac.Field1--;
        }
示例#28
0
 public bool AddReference(IArtifact artifact, System.Threading.ReaderWriterLockSlim locker = null)
 {
     if (this.SynchronizingObject == null || locker == this.SynchronizingObject) return this.InternalAddReference(artifact);
     this.SynchronizingObject.EnterWriteLock();
     try
     {
         return this.InternalAddReference(artifact);
     }
     finally
     {
         this.SynchronizingObject.ExitWriteLock();
     }
 }
示例#29
0
        public override bool ShouldRefuseToAcceptGift(IArtifact artifact)
        {
            Debug.Assert(artifact != null);

            return(((Uid == 5 && artifact.Uid == 8) || (Uid == 14 && artifact.Uid == 51)) ? false : base.ShouldRefuseToAcceptGift(artifact));
        }
示例#30
0
 public IProperty createProperty(IArtifact artifact, string name, object value)
 {
     IProperty property = new Property(artifact, name, value);
     (artifact as Artifact).PropertiesInternal.Add(property);
     return property;
 }
示例#31
0
        public virtual void PrintCantVerbThat(IArtifact artifact)
        {
            Debug.Assert(artifact != null);

            gOut.Print("You can't {0} {1}.", Command.Verb, artifact.EvalPlural("that", "them"));
        }
示例#32
0
 public Property(IArtifact parent, string name, object value)
 {
     _parent = parent;
     _name = name;
     _value = value;
 }
示例#33
0
        public virtual void PrintRemovingFirst(IArtifact artifact)
        {
            Debug.Assert(artifact != null);

            gOut.Print("[Removing {0} first.]", artifact.EvalPlural("it", "them"));
        }
 private IEnumerable<ClassificationSpan> ClassifyArtifact(ITextSnapshot snapshot, IArtifact artifact)
 {
     ITextRange range = artifact;
     // Don't highlight indent for indented code blocks
     if (artifact.LeftSeparator.Length > 0 && artifact.RightSeparator.Length == 0)
         range = artifact.InnerRange;
     yield return new ClassificationSpan(range.ToSnapshotSpan(snapshot), codeType);
 }
示例#35
0
 public override void PrintVerbItAll(IArtifact artifact)
 {
     DrankItAll = true;
 }