Exemplo n.º 1
0
        protected override Errno OnGetPathStatus(string path, out Stat stat)
        {
            logger.DebugFormat("OnGetPathStatus: {0}", path);
            PathStatusDto status;
            stat = new Stat();
            try {
                status = _fileService.GetPathStatus(path);

                if (status.PathType == PathStatusDto.PathTypeEnum.Directory) {
                    stat.st_mode = FilePermissions.S_IFDIR |
                        // Readonly directory
                        NativeConvert.FromOctalPermissionString("0555");
                    stat.st_nlink = 2;
                } else if (status.PathType == PathStatusDto.PathTypeEnum.File) {
                    stat.st_mode = FilePermissions.S_IFREG |
                        // Readonly file.
                        NativeConvert.FromOctalPermissionString("0444");
                    stat.st_nlink = 2;
                    stat.st_size = status.FileSize;
                }
                return 0;
            } catch (FileNotFoundInServiceException) {
                logger.DebugFormat("File not found in service.");
                return Errno.ENOENT;
            } catch (WebException ex) {
                logger.ErrorFormat("Caught WebException: {0} : {1}", ex.Status, ex);
                return Errno.ENONET;
            } catch (Exception ex) {
                logger.ErrorFormat("Exception caught while interacting with File Service : {0}", ex);
                // TODO: Other error more appropriate?
                return Errno.ENONET;
            }
        }
Exemplo n.º 2
0
 public Characteristic(Stat type, int value, int bonus)
 {
     this.type = type;
     this.value = value;
     this.bonus = bonus;
     realvalue = this.value + bonus;
 }
Exemplo n.º 3
0
        protected override Errno OnGetPathStatus(string path, out Stat stbuf)
        {
            stbuf = new Stat ();

            if (path == "/")
            {
                stbuf.st_mode = NativeConvert.FromUnixPermissionString ("dr-xr-xr-x");
                stbuf.st_nlink = 1;
                return 0;
            } // End if (path == "/")

            //if (!files.Contains (path) && !folders.Contains (path))
            if(!files.Any(x => path.Contains(x)) && !folders.Any(x => path.Contains(x)))
                return Errno.ENOENT;

            //if (files.Contains (path))
            if(files.Any(x => path.Contains(x)))
                stbuf.st_mode = NativeConvert.FromUnixPermissionString ("-r--r--r--");
            else if(folders.Any(x => path.Contains(x))) //if (folders.Contains (path))
            {
                stbuf.st_mode = NativeConvert.FromUnixPermissionString ("dr-xr-xr-x");
                //stbuf.st_nlink = 1;
            }
            else
            {
                stbuf.st_mode = NativeConvert.FromUnixPermissionString ("dr-xr-xr-x");
            }
            return 0;
        }
Exemplo n.º 4
0
 public CStats(int mStrength, int mEndurance, int mAglity, int mSpeed)
 {
     Strength = new Stat(mStrength);
     Endurance = new Stat(mEndurance);
     Agility = new Stat(mAglity);
     Speed = new Stat(mSpeed);
 }
Exemplo n.º 5
0
    void Awake()
    {
        player = (IHitManager)GetComponent(typeof(IHitManager));

        health = new Stat(maxHealth, startingHealth);
        //stamina = new Stat(maxStamina, startingStamina);
    }
Exemplo n.º 6
0
    public virtual Action GenerateAction(Stat stat)
    {
        string pattern = actionPattern;

        if (this is BlockCommand)
        {
            pattern = (this as BlockCommand).ApplyScaleAndCritical(stat);
        }

        if (!string.IsNullOrEmpty(animationName))
        {
            pattern = string.Format("Motion({0}; {1})", animationName, pattern);
        }

        if (!string.IsNullOrEmpty(castMotion))
        {
            pattern = string.Format("Cast({0}; {1}; {2})", castMotion, castTime, pattern);
        }

        if (manaConsume > 0)
        {
            pattern = string.Format("Sequence( Action( Self; RecoverMP; -{0}); {1} )", manaConsume, pattern);
        }

        //Debug.LogWarning(pattern);
        return ActionPattern.Create(pattern).Generate(stat);
    }
Exemplo n.º 7
0
        // protected override Errno OnGetFileAttributes (string path, ref Stat stbuf)
        protected override Errno OnGetPathStatus(string path, out Stat stbuf)
        {
            int sep = 0;

            foreach (char c in path)
            {
                if (c == '/')
                    sep++;
            }

            stbuf = new Stat ();

            if (sep < 3)
            {
                stbuf.st_mode = FilePermissions.S_IFDIR | NativeConvert.FromOctalPermissionString ("0755");
                stbuf.st_nlink = 1;
            }
            else
            {
                stbuf.st_mode = FilePermissions.S_IFREG | NativeConvert.FromOctalPermissionString ("0444");
                stbuf.st_nlink = 1;
            }
            stbuf.st_size = 0;

            return 0;
        }
Exemplo n.º 8
0
 public void SetType(itemType type)
 {
     this.type = type;
     switch (type)
     {
         case itemType.계란:
             variation = new Stat(1, 2, 3);
             names = "계란";
             message = "무슨 계란인지 모르겠다.";
             consumable = 1;
             break;
         case itemType.아이템2:
             variation = new Stat(3, 2, 1);
             names = "아이템2";
             message = "아이템 2라고 한다.";
             consumable = 2;
             break;
         case itemType.아이템3:
             variation = new Stat(3, 3, 3);
             names = "아이템3";
             message = "아이템 3이라고 한다.";
             consumable = 3;
             break;
     }
     gameObject.GetComponent<SpriteRenderer>().sprite = graphic[(int)type];
 }
Exemplo n.º 9
0
 public double GetModifier(Stat s)
 {
     if (Bonus == Penalty) return 1;
     if (s == Bonus) return 1.1;
     if (s == Penalty) return 0.9;
     return 1;
 }
Exemplo n.º 10
0
		public virtual void monitorMaster()
		{

			//
			// 监控
			//
			Stat stat = new Stat();
			try
			{

				ZookeeperMgr.Instance.read(monitorPath, this, stat);

			}
			catch (InterruptedException e)
			{

				LOGGER.info(e.ToString());

			}
			catch (KeeperException e)
			{
				LOGGER.error("cannot monitor " + monitorPath, e);
			}

			LOGGER.debug("monitor path: (" + monitorPath + "," + keyName + "," + disConfigTypeEnum.ModelName + ") has been added!");
		}
Exemplo n.º 11
0
	/**
	 * Creates a stat display for the given stat, with the given name.
	 */
	public StatDisplay (string n, Stat s) {
		name = n;
		stat = s;
		// initialize the dimensions of the label fields and button field
		labels = new Rect[5];
		buttons = new Rect[2];
	}
Exemplo n.º 12
0
 public override void Start()
 {
     base.Start();
     Strenght = new Stat("Strenght", 12, 1);
     Agility = new Stat("Agility", 10, 1);
     Intelligence = new Stat("Intelligence", 10, 1);
 }
Exemplo n.º 13
0
        public void CreateAndModifyHealthWithRescaleStat()
        {
            string name = "Strenght";
            float value = 20.0f;
            float firstValue = 0.0f;
            float secondValue = 0.0f;
            float firstPercentage = 0.0f;
            float secondPercentage = 0.0f;
            Stat stat = new Stat(name, value);

            //
            string hName = "Health";
            DerivativeStat hp = new DerivativeStat(stat, StatisticConstants.STRENGHT_TO_HEALTH_SCALE);
            hp.ModifyValue(-100.0f);
            firstValue = hp.CurrentValue;
            firstPercentage = hp.Percentage;

            stat.BaseValue -= value/2;
            secondValue = hp.CurrentValue;
            secondPercentage = hp.Percentage;

            //
            Assert.IsTrue(firstValue > secondValue);
            Assert.IsTrue(firstPercentage == secondPercentage);
        }
Exemplo n.º 14
0
 // Use this for initialization
 void Start()
 {
     nav = GetComponent<NavMeshAgent> ();
     anim = GetComponent<Animator>();
     nav.speed = 12;
     stats = GetComponent<Stat> ();
 }
Exemplo n.º 15
0
    static string ApplyScaleAndCritical(string pattern, Stat stat, BlockType type, float effectFactor, int criticalBuffId)
    {
        float ciriticalFactor = 0;

        if (stat != null)
        {
            if (type == BlockType.Attack1 || type == BlockType.Attack2)
            {
                bool isCritical = RandomTool.IsIn(stat.Get(HeroStatType.criticalHitChance));
                if (isCritical)
                {
                    int parenOpen;
                    int parenclose;
                    SearchParenIndexs(pattern, "PhysicalAttack", out parenOpen, out parenclose);

                    pattern = pattern.Insert(parenclose, "; param=critical");
                    if (criticalBuffId > 0)
                    {
                        pattern = string.Format("Sequence({0}; Action(Contact; Buff; {1}) )", pattern, criticalBuffId);
                    }
                    ciriticalFactor = stat.Get(HeroStatType.criticalHitDamageFactor);
                }
            }
        }
        return string.Format(pattern, 1 + effectFactor + ciriticalFactor);
    }
Exemplo n.º 16
0
    public InGameUser(StageEntity2 stageEntity, Status.Handle onGoldChanged, TimedConsumableCommandSet.Handle onChargedAttack)
    {
        this.stat = new Stat<PlayerStatType>(StatGenerator.ExportData<PlayerStatType>(stageEntity, new StatConstants()));
        this.status = new Status<PlayerStatusType>(null, stat);
        status.InitMinMaxVal(PlayerStatusType.exp, 0, PlayerStatType.maxEXP, 0);
        status.InitMinMaxVal(PlayerStatusType.gold, 0, PlayerStatType.maxGold, 0);
        status.InitMinMaxVal(PlayerStatusType.key, 0, PlayerStatType.maxKey, 0);
        status.InitMinMaxVal(PlayerStatusType.feverPoint, 0, PlayerStatType.maxFeverPoint, 0);

        /*
        actionHandler = new ActionHandler(status);
        AddAction(Action.E_Type.Money,
            delegate(float value, GameInstance firer, string[] param)
            {
                return new ActionHandler.Result(PlayerStatusType.gold, value);
            }
        );
        AddAction(Action.E_Type.Exp,
            delegate(float value, GameInstance firer, string[] param)
            {
                return new ActionHandler.Result(PlayerStatusType.exp, value);
            }
        );
        */

        status.RegisterOnChangeEvent(PlayerStatusType.gold, onGoldChanged);

        commandQueue = new TimedConsumableCommandSet(100, false, null, onChargedAttack);
    }
Exemplo n.º 17
0
 public static void CalcStats(string inputNaj, string outputName)
 {
     var fsa = new FsaNajka(File.OpenRead(inputNaj));
     var stats = new Dictionary<char, Stat>();
     fsa.IterateAllRaw(sb =>
     {
         var parts = sb.ToString().Split(':');
         if (parts.Length != 3) return;
         var s = parts[2];
         Stat stat;
         if (!stats.TryGetValue(s[1], out stat))
         {
             stat = new Stat();
             stats[s[1]] = stat;
         }
         for (var i = 0; i < s.Length - 1; i += 2)
         {
             stat.Inc(s.Substring(i, 2), parts[0]);
         }
     });
     using (var o=File.CreateText(outputName))
         foreach (var stat in stats.OrderBy(p=>p.Key))
         {
             o.WriteLine("Kind "+stat.Key);
             o.WriteLine(stat.Value);
         }
 }
 /// <summary>
 /// </summary>
 /// <param name="dependency"> </param>
 private void SetupDepends(Stat<decimal> dependency)
 {
     AddDependency(dependency);
     UpdateTimer = new Timer(1000);
     UpdateTimer.Elapsed += UpdateTimerOnElapsed;
     UpdateTimer.Start();
 }
Exemplo n.º 19
0
		public GameState(Mood _mood) {
			Stats = new Stat[4];
			Stats[0] = new Stat();
			Stats[0].Name = "Food";
			Stats[0].Value = 100;
			Stats[0].IsNeeded = false;
			Stats[0].IsCritical = false;
			Stats[1] = new Stat();
			Stats[1].Name = "Drink";
			Stats[1].Value = 100;
			Stats[1].IsNeeded = false;
			Stats[1].IsCritical = false;
			Stats[2] = new Stat();
			Stats[2].Name = "Hygiene";
			Stats[2].Value = 100;
			Stats[2].IsNeeded = false;
			Stats[2].IsCritical = false;
			Stats[3] = new Stat();
			Stats[3].Name = "Activities";
			Stats[3].Value = 100;
			Stats[3].IsNeeded = false;
			Stats[3].IsCritical = false;

			Score = 0;
			Life = 100;
			mood = _mood;

		}
Exemplo n.º 20
0
 protected override Errno OnGetPathStatus(string path, out Stat stbuf)
 {
     VFileInfo info;
     data.GetFileInformation (path, out info);
     // return Errno.ENOENT;
     stbuf = new Stat ();
     stbuf.st_mode = info.IsDirectory () ? FilePermissions.S_IFDIR : FilePermissions.S_IFREG;
     stbuf.st_atime = info.LastAccessTime.ToUnix ();
     stbuf.st_ctime = info.CreationTime.ToUnix ();
     stbuf.st_mtime = info.LastWriteTime.ToUnix ();
     stbuf.st_mtime_nsec = info.LastWriteTime.Nanoseconds();
     stbuf.st_size = info.IsDirectory () ? 0 : info.Length;
     stbuf.st_uid = Syscall.getuid ();
     stbuf.st_gid = Syscall.getgid ();
     switch (path) {
     case "/":
         stbuf.st_mode |= NativeConvert.FromOctalPermissionString ("0755");
         stbuf.st_nlink = 2;
         break;
     default:
         stbuf.st_mode |= NativeConvert.FromOctalPermissionString ("0444");
         stbuf.st_nlink = 1;
         break;
     }
     return 0;
 }
Exemplo n.º 21
0
        public static void ChangeStatLock(int client, Stat stat, StatLockStatus statLockStatus)
        {
            byte[] packet = new byte[] { 0xBF, 0x00, 0x07, 0x00, 0x1A, 0x00, 0x00 };

            switch (stat)
            {
                case Stat.Strength:
                    packet[5] = 0x00;
                    break;
                case Stat.Dexterity:
                    packet[5] = 0x01;
                    break;
                case Stat.Intelligence:
                    packet[5] = 0x02;
                    break;
            }

            switch (statLockStatus)
            {
                case StatLockStatus.Up:
                    packet[6] = 0x00;
                    break;
                case StatLockStatus.Down:
                    packet[6] = 0x01;
                    break;
                case StatLockStatus.Locked:
                    packet[6] = 0x02;
                    break;
            }

            SendPacketToServer(client, packet);
        }
Exemplo n.º 22
0
 internal CuratorEventImpl(CuratorFrameworkImpl client, 
                     CuratorEventType type, 
                     int resultCode, 
                     String path, 
                     String name, 
                     Object context, 
                     Stat stat, 
                     byte[] data, 
                     List<String> children, 
                     WatchedEvent watchedEvent, 
                     List<ACL> aclList)
 {
     this.type = type;
     this.resultCode = resultCode;
     this.path = client.unfixForNamespace(path);
     this.name = name;
     this.context = context;
     this.stat = stat;
     this.data = data;
     this.children = children;
     this.watchedEvent = (watchedEvent != null)
                             ? new NamespaceWatchedEvent(client, watchedEvent)
                             : watchedEvent;
     this.aclList = (aclList != null)
                         ? new ReadOnlyCollectionBuilder<ACL>(aclList).ToReadOnlyCollection()
                         : null;
 }
Exemplo n.º 23
0
        protected override Errno OnGetPathStatus(string path, out Stat stat)
        {
            stat = new Stat();

            FlacFsObjectInfo fsoi = flacFs_.GetFsObjectInfo(path);
            if (fsoi == null)
            {
                return Errno.ENOENT;
            }

            if ((fsoi.Attributes & FileAttributes.Directory) == FileAttributes.Directory)
            {
                stat.st_mode = FilePermissions.S_IFDIR | NativeConvert.FromOctalPermissionString("0755");
                stat.st_nlink = 2;
            }
            else
            {
                stat.st_mode = FilePermissions.S_IFREG | NativeConvert.FromOctalPermissionString("0444");
                stat.st_nlink = 1;
            }

            stat.st_ctime = Mono.Unix.Native.NativeConvert.FromDateTime(fsoi.LastWriteTime);
            stat.st_atime = Mono.Unix.Native.NativeConvert.FromDateTime(fsoi.LastAccessTime);
            stat.st_mtime = Mono.Unix.Native.NativeConvert.FromDateTime(fsoi.LastWriteTime);
            stat.st_size = fsoi.Length;
            return 0;
        }
Exemplo n.º 24
0
Arquivo: Buff.cs Projeto: pb0/ID0_Test
    public static Buff ToBuff(Stat stat)
    {
        var members = EnumTool.GetNames(stat.KeyType);
        Dictionary<Enum, float> values = new Dictionary<Enum, float>();
        for (int i = 1; true; i++)
        {
            string form1 = string.Format("Stat{0}Type", i);
            string form2 = string.Format("Stat{0}Value", i);
            if (members.Contains(form1) && members.Contains(form2))
            {
                Enum statType = stat.GetRawValue(EnumTool.Parse(stat.KeyType.Name, form1) as Enum) as Enum;
                float value = stat.Get(EnumTool.Parse(stat.KeyType.Name, form2) as Enum);
                if (statType.ToString() != "None")
                {
                    values.Add(statType, value);
                }
            }
            else
            {
                break;
            }
        }

        string name = stat.KeyType.ToString() + stat.Get(EnumTool.Parse(stat.KeyType, "ID") as Enum);
        float duration = float.MaxValue;
        return new Buff(name, duration, values);
    }
 public void Check_For_Wrong_Stats(ref Equipment_Foundation Weapon_Editor, Stat Select_Stat)
 {
     if (Weapon_Editor.Get_Stat(Select_Stat) != 0)
     {
         EditorGUILayout.HelpBox(Select_Stat.ToString() + " is not equal to zero, if this is okay contact me",MessageType.Warning);
     }
 }
Exemplo n.º 26
0
        internal Stat fstat(string path)
        {
            System.IO.FileSystemInfo fsi;
            if (System.IO.Directory.Exists(path))
                fsi = new System.IO.DirectoryInfo(path);
            else if (System.IO.File.Exists(path))
                fsi = new System.IO.FileInfo(path);
            else
                throw SystemCallError.rb_sys_fail(path, new System.IO.FileNotFoundException("", path), null).raise(null);

            Stat st = new Stat();
            st.fsi = fsi;
            st.st_dev = (int)fsi.FullName.ToCharArray(0,1)[0];  // drive letter as int, what to do for networked files?
            st.st_ino = 0; // no inode on win32
            st.st_mode = 0;
            st.st_nlink = 1; // no symbolic link support on win32
            st.st_uid = 0;  // no uid in win32
            st.st_gid = 0; // no gid in win32
            //st.st_rdev = 0; // no rdev in win32
            st.st_size = (fsi is System.IO.FileInfo) ? ((System.IO.FileInfo)fsi).Length : 0;
            //st.st_blksize = 0; // no blksize in win32
            //st.st_blocks = 0; // no blocks in win32
            st.st_atime = fsi.LastAccessTime;
            st.st_mtime = fsi.LastWriteTime;
            st.st_ctime = fsi.CreationTime;

            return st;
        }
Exemplo n.º 27
0
		public override void DoImport(SCObjectSet objectSet, IImportContext context)
		{
			if (objectSet.HasRelations && objectSet.HasObjects)
			{
				context.SetStatus(0, 1, "正在分析数据。");

				// 查找组织关系
				var pendingOperations = new List<Action<object>>();

				var objects = objectSet.Objects;
				Dictionary<string, IList<PC.SCOrganization>> orgToOrgRelations = new Dictionary<string, IList<PC.SCOrganization>>();
				Dictionary<string, IList<PC.SCUser>> orgToUserRelations = new Dictionary<string, IList<PC.SCUser>>();
				Dictionary<string, IList<PC.SCGroup>> orgToGroupRelations = new Dictionary<string, IList<PC.SCGroup>>();
				Dictionary<string, PC.SchemaObjectBase> knownObjects = new Dictionary<string, PC.SchemaObjectBase>(); // 缓存已知对象,避免多次往返

				context.SetStatus(0, 1, "正在统计需要导入的对象");
				Stat stat = new Stat(); // 统计信息

				FindFullOURelations(objectSet, orgToOrgRelations, orgToUserRelations, orgToGroupRelations, new PC.SCOrganization[] { this.Parent }, stat); // 爬出所有组织关系

				Dictionary<PC.SCOrganization, IList<PC.SCRelationObject>> userToOrgRelations = new Dictionary<PC.SCOrganization, IList<PC.SCRelationObject>>();

				this.allSteps = this.CalculateSteps(stat);
				this.currentSteps = 0;
				bool orgValid = false; // 必须校验组织
				context.SetStatus(0, this.allSteps, "正在导入数据。");

				// 递归导入组织,并剔除错误的数据
				orgValid = this.PrepareOrganizations(objectSet, context, knownObjects, orgToOrgRelations, this.Parent, this.IncludeOrganizations == false);

				if (this.IncludeAcl)
				{
					// 递归导入Acl
					var action = new AclAction(this);
					action.ExecutePreOperation(objectSet, context, knownObjects, this.Parent, orgToOrgRelations, orgToUserRelations, orgToGroupRelations);
					this.DoHierarchicalAction(objectSet, context, knownObjects, orgToOrgRelations, orgToUserRelations, orgToGroupRelations, this.Parent, action);
					action.ExecutePostOperation(objectSet, context, knownObjects, this.Parent, orgToOrgRelations, orgToUserRelations, orgToGroupRelations);
				}

				if (this.IncludeUser)
				{
					var action = new UserAction(this);
					action.ImportSecretaries = this.IncludeSecretaries;
					action.ExecutePreOperation(objectSet, context, knownObjects, this.Parent, orgToOrgRelations, orgToUserRelations, orgToGroupRelations);
					this.DoHierarchicalAction(objectSet, context, knownObjects, orgToOrgRelations, orgToUserRelations, orgToGroupRelations, this.Parent, action);
					action.ExecutePostOperation(objectSet, context, knownObjects, this.Parent, orgToOrgRelations, orgToUserRelations, orgToGroupRelations);
				}

				if (this.IncludeGroup)
				{
					var action = new GroupAction(this);
					action.ImportMembers = this.IncludeGroupMembers;
					action.ImportConditions = this.IncludeGroupConditions;
					action.ExecutePreOperation(objectSet, context, knownObjects, this.Parent, orgToOrgRelations, orgToUserRelations, orgToGroupRelations);
					this.DoHierarchicalAction(objectSet, context, knownObjects, orgToOrgRelations, orgToUserRelations, orgToGroupRelations, this.Parent, action);
					action.ExecutePostOperation(objectSet, context, knownObjects, this.Parent, orgToOrgRelations, orgToUserRelations, orgToGroupRelations);
				}
			}
		}
Exemplo n.º 28
0
 public Stat(Stat argStat)
 {
     displayData.name = argStat.displayData.name;
     displayData.shortName = argStat.displayData.shortName;
     current = argStat.Current;
     ourPrevious = argStat.ourPrevious;
     StatChanged = argStat.StatChanged;
 }
Exemplo n.º 29
0
 // Use this for initialization
 void Start()
 {
     vitality = new Stat<int>("Vitality", 70);
     strength = new Stat<int>("Strength", 70);
     health = new Stat<int>("Health", vitality.Value * 50);
     critChance = new Stat<float>("Critical Hit Chance", 5f);
     critDmg = new Stat<float>("Critical Hit Damage", 50f);
 }
Exemplo n.º 30
0
 //will load statistics from LocalStorage
 public GameStatistics()
 {
     overall = read("Overall");
     other[index(DifficultyLevel.EASY, CoreCZ.Side.Cross)] = read(key(DifficultyLevel.EASY, CoreCZ.Side.Cross));
     other[index(DifficultyLevel.EASY, CoreCZ.Side.Zero )] =  read(key(DifficultyLevel.EASY, CoreCZ.Side.Zero));
     other[index(DifficultyLevel.HARD, CoreCZ.Side.Cross)] = read(key(DifficultyLevel.HARD, CoreCZ.Side.Cross));
     other[index(DifficultyLevel.HARD, CoreCZ.Side.Zero )] =  read(key(DifficultyLevel.HARD, CoreCZ.Side.Zero));
 }
Exemplo n.º 31
0
 public StatButton(Stat type, float height, float width)
 {
     this.type   = type;
     this.height = height;
     this.width  = width;
 }
Exemplo n.º 32
0
        public static void IncreaseStat(Mobile from, Stat stat, bool atrophy)
        {
            atrophy = atrophy || (from.RawStatTotal >= from.StatCap);

            switch (stat)
            {
            case Stat.Str:
            {
                if (atrophy)
                {
                    if (CanLower(from, Stat.Dex) && (from.RawDex < from.RawInt || !CanLower(from, Stat.Int)))
                    {
                        --from.RawDex;
                    }
                    else if (CanLower(from, Stat.Int))
                    {
                        --from.RawInt;
                    }
                }

                if (CanRaise(from, Stat.Str))
                {
                    ++from.RawStr;
                }

                break;
            }

            case Stat.Dex:
            {
                if (atrophy)
                {
                    if (CanLower(from, Stat.Str) && (from.RawStr < from.RawInt || !CanLower(from, Stat.Int)))
                    {
                        --from.RawStr;
                    }
                    else if (CanLower(from, Stat.Int))
                    {
                        --from.RawInt;
                    }
                }

                if (CanRaise(from, Stat.Dex))
                {
                    ++from.RawDex;
                }

                break;
            }

            case Stat.Int:
            {
                if (atrophy)
                {
                    if (CanLower(from, Stat.Str) && (from.RawStr < from.RawDex || !CanLower(from, Stat.Dex)))
                    {
                        --from.RawStr;
                    }
                    else if (CanLower(from, Stat.Dex))
                    {
                        --from.RawDex;
                    }
                }

                if (CanRaise(from, Stat.Int))
                {
                    ++from.RawInt;
                }

                break;
            }
            }
        }
Exemplo n.º 33
0
        public static void GainStat(Mobile from, Stat stat)
        {
            switch (stat)
            {
            case Stat.Str:
            {
                if (from is BaseCreature && ((BaseCreature)from).Controlled)
                {
                    if ((from.LastStrGain + m_PetStatGainDelay) >= DateTime.UtcNow)
                    {
                        return;
                    }
                }
                else if ((from.LastStrGain + m_StatGainDelay) >= DateTime.UtcNow)
                {
                    return;
                }

                from.LastStrGain = DateTime.UtcNow;
                break;
            }

            case Stat.Dex:
            {
                if (from is BaseCreature && ((BaseCreature)from).Controlled)
                {
                    if ((from.LastDexGain + m_PetStatGainDelay) >= DateTime.UtcNow)
                    {
                        return;
                    }
                }
                else if ((from.LastDexGain + m_StatGainDelay) >= DateTime.UtcNow)
                {
                    return;
                }

                from.LastDexGain = DateTime.UtcNow;
                break;
            }

            case Stat.Int:
            {
                if (from is BaseCreature && ((BaseCreature)from).Controlled)
                {
                    if ((from.LastIntGain + m_PetStatGainDelay) >= DateTime.UtcNow)
                    {
                        return;
                    }
                }

                else if ((from.LastIntGain + m_StatGainDelay) >= DateTime.UtcNow)
                {
                    return;
                }

                from.LastIntGain = DateTime.UtcNow;
                break;
            }
            }

            bool atrophy = ((from.RawStatTotal / (double)from.StatCap) >= Utility.RandomDouble());

            IncreaseStat(from, stat, atrophy);
        }
Exemplo n.º 34
0
        public string GetDisplay(Stat stat)
        {
            Type type = stat.GetType();

            MemberInfo[] infos = type.GetMember(stat.ToString());

            StatDescription description = infos[0].GetCustomAttribute <StatDescription>();

            if (description == null)
            {
                return(null);
            }

            List <Stat> list;
            string      value;
            bool        neecComma;

            switch (description.Mode)
            {
            case StatType.None:
                return(null);

            case StatType.Default:
                return(description.Title + ": " + string.Format(description.Format, this[stat]));

            case StatType.Min:
                if (this[description.MaxStat] != 0)
                {
                    return(null);
                }

                return(description.Title + ": " + string.Format(description.Format, this[stat]));

            case StatType.Max:
                return(description.Title + ": " + string.Format(description.Format, this[description.MinStat], this[stat]));

            case StatType.Percent:
                return(description.Title + ": " + string.Format(description.Format, this[stat] / 100D));

            case StatType.Text:
                return(description.Title);

            case StatType.Time:
                if (this[stat] < 0)
                {
                    return(description.Title + ": Permanent");
                }

                return(description.Title + ": " + Functions.ToString(TimeSpan.FromSeconds(this[stat]), true));

            case StatType.SpellPower:
                if (description.MinStat == stat && this[description.MaxStat] != 0)
                {
                    return(null);
                }

                if (this[Stat.MinMC] != this[Stat.MinSC] || this[Stat.MaxMC] != this[Stat.MaxSC])
                {
                    return(description.Title + ": " + string.Format(description.Format, this[description.MinStat], this[stat]));
                }

                if (stat != Stat.MaxSC)
                {
                    return(null);
                }


                return("Spell Power: " + string.Format(description.Format, this[description.MinStat], this[stat]));

            case StatType.AttackElement:

                list = new List <Stat>();
                foreach (KeyValuePair <Stat, int> pair in Values)
                {
                    if (type.GetMember(pair.Key.ToString())[0].GetCustomAttribute <StatDescription>().Mode == StatType.AttackElement)
                    {
                        list.Add(pair.Key);
                    }
                }

                if (list.Count == 0 || list[0] != stat)
                {
                    return(null);
                }

                value = $"E. Atk: ";

                neecComma = false;
                foreach (Stat s in list)
                {
                    description = type.GetMember(s.ToString())[0].GetCustomAttribute <StatDescription>();

                    if (neecComma)
                    {
                        value += $", ";
                    }

                    value    += $"{description.Title} +" + this[s];
                    neecComma = true;
                }
                return(value);

            case StatType.ElementResistance:


                list = new List <Stat>();
                foreach (KeyValuePair <Stat, int> pair in Values)
                {
                    if (type.GetMember(pair.Key.ToString())[0].GetCustomAttribute <StatDescription>().Mode == StatType.ElementResistance)
                    {
                        list.Add(pair.Key);
                    }
                }

                if (list.Count == 0)
                {
                    return(null);
                }

                bool ei;
                bool hasAdv = false, hasDis = false;

                foreach (Stat s in list)
                {
                    if (this[s] > 0)
                    {
                        hasAdv = true;
                    }

                    if (this[s] < 0)
                    {
                        hasDis = true;
                    }
                }

                if (!hasAdv)     // EV Online
                {
                    ei = false;

                    if (list[0] != stat)
                    {
                        return(null);
                    }
                }
                else
                {
                    if (!hasDis && list[0] != stat)
                    {
                        return(null);
                    }

                    ei = list[0] == stat;

                    if (!ei && list[1] != stat)
                    {
                        return(null);                            //Impossible to be false and have less than 2 stats.
                    }
                }


                value = ei ? $"E. Adv: " : $"E. Dis: ";

                neecComma = false;


                foreach (Stat s in list)
                {
                    description = type.GetMember(s.ToString())[0].GetCustomAttribute <StatDescription>();

                    if ((this[s] > 0) != ei)
                    {
                        continue;
                    }

                    if (neecComma)
                    {
                        value += $", ";
                    }

                    value    += $"{description.Title} x" + Math.Abs(this[s]);
                    neecComma = true;
                }

                return(value);

            default: return(null);
            }
        }
Exemplo n.º 35
0
 public int GetLevels(Stat stat, CharacterClass characterClass)
 {
     BuildLookup();
     float[] levels = lookupTable[characterClass][stat];
     return(levels.Length);
 }
Exemplo n.º 36
0
 public void Edit(Stat stat)
 {
     _context.UpdateRange(stat);
 }
Exemplo n.º 37
0
        public async Task <IActionResult> Stats(int id)
        {
            var user = await _userManager.GetUserAsync(HttpContext.User);

            var test = await _context.Tests.SingleOrDefaultAsync(t => t.Id == id);

            if (test.CreatedById != user.Id)
            {
                Forbid();
            }
            var questions = _context.Questions.Where(q => q.TestId == test.Id && !q.IsDeleted);
            var stat      = new Stat {
                TestName = test.Name, TestId = test.Id
            };

            foreach (var question in questions)
            {
                QuestionStat questionStat = new QuestionStat
                {
                    QuestionId    = question.Id,
                    QuestionType  = question.GetTypeString(),
                    QuestionTitle = question.Title
                };
                var answersForQuestion = _context.Answers.Where(a => a.QuestionId == question.Id);
                questionStat.MaxScore = question.Score;
                float averageSum = 0, derivationSum = 0;
                int   n = 0;
                foreach (var answer in answersForQuestion)
                {
                    switch (answer.Result)
                    {
                    case null:
                    {
                        questionStat.NullCount++;
                        break;
                    }

                    case AnswerResult.Wrong:
                    {
                        questionStat.WrongCount++;
                        break;
                    }

                    case AnswerResult.PartiallyRight:
                    {
                        questionStat.PartiallyRightCount++;
                        break;
                    }

                    case AnswerResult.Right:
                    {
                        questionStat.RightCount++;
                        break;
                    }
                    }
                    n++;
                    averageSum    += answer.Score;
                    derivationSum += answer.Score * answer.Score;
                }

                var average = averageSum / n;
                var derivationSumAverage = derivationSum / n;
                var stDer = Math.Sqrt(derivationSumAverage - (average * average));
                questionStat.AverageScore            = (float)Math.Round(average, 2);
                questionStat.ScoreStandartDerivation = (float)Math.Round(stDer, 2);
                stat.QuestionStats.Add(questionStat);
            }

            stat.MostDifficult = questions.SingleOrDefault(x => x.Id == stat.GetMostDifficultId());
            stat.MostEasy      = questions.SingleOrDefault(x => x.Id == stat.GetMostEasyId());
            return(View("Stat", stat));
        }
Exemplo n.º 38
0
 // Use this for initialization
 void Start()
 {
     healthStat = targetFrame.GetComponentInChildren <Stat>();
 }
Exemplo n.º 39
0
        internal override void ParseResponseBody(System.IO.Stream inputStream,
                                                 string contentType, long contentLength)
        {
            // Read One Message for each loop
            // readToString(inputStream);
            System.IO.Stream outputStream;
            if (outputFilePath != null)
            {
                outputStream = new System.IO.FileStream(outputFilePath, FileMode.Create);
            }
            else
            {
                outputStream = new MemoryStream();
            }

            using (outputStream) {
                byte[] tempBuffer = new byte[4];

                while (true)
                {
                    tryRead(inputStream, tempBuffer, 0, 4);
                    long messageEntireLength = bytes4ToInt(tempBuffer);

                    tryRead(inputStream, tempBuffer, 0, 4);
                    long headerSectionLength = bytes4ToInt(tempBuffer);

                    tryRead(inputStream, tempBuffer, 0, 4);
                    long preludeCRC = bytes4ToInt(tempBuffer);

                    Dictionary <String, String> headers = new Dictionary <string, string>();

                    // read header
                    long headerSectionRemainLength = headerSectionLength;
                    while (headerSectionRemainLength > 0)
                    {
                        tryRead(inputStream, tempBuffer, 0, 1);
                        int headerNameLength = bytes1ToInt(tempBuffer);

                        byte[] headerNameBuffer = new byte[headerNameLength];
                        tryRead(inputStream, headerNameBuffer, 0, headerNameLength);
                        String headerName = bytes2stringUTF8(headerNameBuffer);

                        // 7
                        inputStream.ReadByte();

                        tryRead(inputStream, tempBuffer, 0, 2);
                        int valueLength = bytes2ToInt(tempBuffer);

                        byte[] valueBuffer = new byte[valueLength];
                        tryRead(inputStream, valueBuffer, 0, valueLength);
                        String value = bytes2stringUTF8(valueBuffer);

                        if (headers.ContainsKey(headerName))
                        {
                            headers.Remove(headerName);
                        }
                        headers.Add(headerName, value);

                        headerSectionRemainLength -= 1 + headerNameLength + 3 + valueLength;
                    }

                    long payloadLength = messageEntireLength - headerSectionLength - 16;

                    string messageType;
                    headers.TryGetValue(":message-type", out messageType);
                    string eventType;
                    headers.TryGetValue(":event-type", out eventType);
                    Console.WriteLine("message = " + messageType + ", event = " + eventType);

                    bool isComplete = false;

                    if ("event".Equals(messageType))
                    {
                        byte[] buffer;

                        switch (eventType)
                        {
                        case "Records":
                            int totalRead = 0;
                            buffer = new byte[1024];
                            while (payloadLength > totalRead)
                            {
                                int readLength = (int)Math.Min(payloadLength - totalRead, 1024);
                                int readBytes  = tryRead(inputStream, buffer, 0, readLength);
                                outputStream.Write(buffer, 0, readBytes);
                                totalRead += readBytes;
                            }
                            break;

                        case "Progress":
                            buffer = new byte[payloadLength];
                            tryRead(inputStream, buffer, 0, (int)payloadLength);
                            Stat stat = parseStatsBody(buffer);
                            progressCallback(stat.BytesProcessed, stat.BytesScanned);
                            break;

                        case "Cont":
                            buffer = new byte[payloadLength];
                            tryRead(inputStream, buffer, 0, (int)payloadLength);
                            break;

                        case "Stats":
                            buffer = new byte[payloadLength];
                            tryRead(inputStream, buffer, 0, (int)payloadLength);
                            this.stat = parseStatsBody(buffer);
                            break;

                        case "End":
                        default:
                            isComplete = true;
                            break;
                        }
                    }
                    else if ("error".Equals(messageType))
                    {
                        string errorCode    = null;
                        string errorMessage = null;
                        headers.TryGetValue(":error-code", out errorCode);
                        headers.TryGetValue(":error-message", out errorMessage);

                        throw new System.IO.IOException(string.Format(
                                                            "search error happends with code :{0} and message: {1}",
                                                            errorCode, errorMessage));
                    }

                    if (isComplete)
                    {
                        if (outputFilePath == null)
                        {
                            outputStream.Position = 0;
                            searchContent         = readToString(outputStream);
                        }
                        break;
                    }

                    tryRead(inputStream, tempBuffer, 0, 4);
                    long messageCRC = bytes4ToInt(tempBuffer);
                }
            }
        }
Exemplo n.º 40
0
 //Methods
 /// <summary>
 /// Updates internal statistics
 /// </summary>
 /// <param name="sample">Feature sample value</param>
 public virtual void Update(double sample)
 {
     Stat.AddSampleValue(sample);
     return;
 }
 public void HasCalculatesCorrectly(Tags queryTags)
 {
     var slotTags    = Tags.Armour | Tags.BodyArmour | Tags.StrArmour;
     var tagsStat    = new Stat("BodyArmour.ItemTags");
     var statFactory = Mock.Of <IStatFactory>(f =>
                                              f.FromIdentity("BodyArmour.ItemTags", default, typeof(Tags), null) == tagsStat);
Exemplo n.º 42
0
        //public async Task AddAsync(IEnumerable<Stat> stats)
        //{
        //    await _context.Stats.AddRangeAsync(stats);
        //}

        public async Task AddAsync(Stat stat)
        {
            await _context.Stats.AddAsync(stat);
        }
Exemplo n.º 43
0
 public Artifact(Stat stat)
 {
     MainStat = stat;
 }
Exemplo n.º 44
0
        public override bool Drank(LiquidVolume Liquid, int Volume, GameObject Target, StringBuilder Message, ref bool ExitInterface)
        {
            long turns = XRLCore.Core.Game.Turns;

            if (Target.HasPart("Stomach"))
            {
                Stomach part = Target.GetPart <Stomach>();
                Target.FireEvent(Event.New("AddWater", "Amount", 2 * Volume, "Forced", 1));
                Target.FireEvent(Event.New("AddFood", "Satiation", "Snack"));
                Message.Append("It is sweet and delicious.\n");
                Message.Append("You are now " + part.FoodStatus() + ".");
            }
            if (!Target.Property.ContainsKey("ConfuseOnEatTurnWine"))
            {
                Target.Property.Add("ConfuseOnEatTurnWine", XRLCore.Core.Game.Turns.ToString());
            }
            if (!Target.Property.ContainsKey("ConfuseOnEatAmountWine"))
            {
                Target.Property.Add("ConfuseOnEatAmountWine", "0");
            }
            long longProperty = Target.GetLongProperty("ConfuseOnEatTurnWine");
            int  num          = (int)Target.GetLongProperty("ConfuseOnEatAmountWine");

            if (turns - longProperty > 80)
            {
                num = 0;
            }
            if (num > Math.Max(1, Target.Statistics["Toughness"].Modifier * 2) && Target.ApplyEffect(new Confused(Stat.Roll("5d5"), 1, 3)))
            {
                ExitInterface = true;
            }
            Target.SetLongProperty("ConfuseOnEatTurnWine", turns);
            Target.Property["ConfuseOnEatAmountWine"] = (num + 1).ToString();
            return(true);
        }
Exemplo n.º 45
0
 public StatButton(Stat type, float diameter) : this(type, diameter, diameter)
 {
 }
Exemplo n.º 46
0
    public void StatsSelector(List <Text> statsText)
    {
        int limitPoints = iVsLimit;

        if (isEVsEditor)
        {
            limitPoints = eVsLimit;
        }

        Stat choicedStat = Stat.Hp;

        if (statSelector == 1) //hp
        {
            choicedStat = Stat.Hp;
        }
        else if (statSelector == 2) //Attack
        {
            choicedStat = Stat.Attack;
        }
        else if (statSelector == 3) //Defense
        {
            choicedStat = Stat.Defense;
        }
        else if (statSelector == 4) //SpAttack
        {
            choicedStat = Stat.SpAttack;
        }
        else if (statSelector == 5) //SpDefense
        {
            choicedStat = Stat.SpDefense;
        }
        else if (statSelector == 6) //Speed
        {
            choicedStat = Stat.Speed;
        }

        if (Input.GetKeyDown(KeyCode.LeftArrow))
        {
            leftKeyDown = true;
        }
        else if (Input.GetKeyDown(KeyCode.RightArrow))
        {
            rightKeyDown = true;
        }

        if (isEVsEditor)
        {
            statPoints = playerController.GetComponent <PokemonParty>().Pokemons[currentTeamBuildOption].EV[choicedStat];
        }
        else
        {
            statPoints = playerController.GetComponent <PokemonParty>().Pokemons[currentTeamBuildOption].IV[choicedStat];
        }


        if (leftKeyDown)
        {
            if (statPoints > 0)
            {
                if (timerPause <= 0)
                {
                    if (isEVsEditor)
                    {
                        statPoints -= 4;
                        playerController.GetComponent <PokemonParty>().Pokemons[currentTeamBuildOption].EV[choicedStat] = statPoints;
                        RefreshStatEditor();
                    }
                    else
                    {
                        statPoints--;
                        playerController.GetComponent <PokemonParty>().Pokemons[currentTeamBuildOption].IV[choicedStat] = statPoints;
                        RefreshStatEditor();
                    }

                    statsText[statSelector].text = statPoints.ToString();
                    timerPause = pauseDuration;
                }
                else
                {
                    timerPause -= Time.deltaTime;
                }
            }
        }
        if (rightKeyDown)
        {
            if (statPoints < limitPoints)
            {
                if (timerPause <= 0)
                {
                    if (isEVsEditor)
                    {
                        if (eVsGlobalLimit > playerController.GetComponent <PokemonParty>().Pokemons[currentTeamBuildOption].GetAllEvsSum())
                        {
                            statPoints += 4;
                            playerController.GetComponent <PokemonParty>().Pokemons[currentTeamBuildOption].EV[choicedStat] = statPoints;
                            RefreshStatEditor();
                        }
                    }
                    else
                    {
                        statPoints++;
                        playerController.GetComponent <PokemonParty>().Pokemons[currentTeamBuildOption].IV[choicedStat] = statPoints;
                        RefreshStatEditor();
                    }
                    statsText[statSelector].text = statPoints.ToString();
                    timerPause = pauseDuration;
                }
                else
                {
                    timerPause -= Time.deltaTime;
                }
            }
        }

        if (Input.GetKeyUp(KeyCode.LeftArrow))
        {
            leftKeyDown = false;
            timerPause  = 0;
        }
        if (Input.GetKeyUp(KeyCode.RightArrow))
        {
            rightKeyDown = false;
            timerPause   = 0;
        }
    }
Exemplo n.º 47
0
        public static void IncreaseStat(Mobile from, Stat stat)
        {
            bool atTotalCap = from.RawStatTotal >= from.StatCap;

            switch (stat)
            {
            case Stat.Str:
            {
                if (CanRaise(from, Stat.Str, atTotalCap))
                {
                    if (atTotalCap)
                    {
                        if (CanLower(from, Stat.Dex) && (from.RawDex < from.RawInt || !CanLower(from, Stat.Int)))
                        {
                            --from.RawDex;
                        }
                        else if (CanLower(from, Stat.Int))
                        {
                            --from.RawInt;
                        }
                    }

                    ++from.RawStr;

                    if (from is BaseCreature && ((BaseCreature)from).HitsMaxSeed > -1 && ((BaseCreature)from).HitsMaxSeed < from.StrCap)
                    {
                        ((BaseCreature)from).HitsMaxSeed++;
                    }

                    if (Siege.SiegeShard && from is PlayerMobile)
                    {
                        Siege.IncreaseStat((PlayerMobile)from);
                    }
                }

                break;
            }

            case Stat.Dex:
            {
                if (CanRaise(from, Stat.Dex, atTotalCap))
                {
                    if (atTotalCap)
                    {
                        if (CanLower(from, Stat.Str) && (from.RawStr < from.RawInt || !CanLower(from, Stat.Int)))
                        {
                            --from.RawStr;
                        }
                        else if (CanLower(from, Stat.Int))
                        {
                            --from.RawInt;
                        }
                    }

                    ++from.RawDex;

                    if (from is BaseCreature && ((BaseCreature)from).StamMaxSeed > -1 && ((BaseCreature)from).StamMaxSeed < from.DexCap)
                    {
                        ((BaseCreature)from).StamMaxSeed++;
                    }

                    if (Siege.SiegeShard && from is PlayerMobile)
                    {
                        Siege.IncreaseStat((PlayerMobile)from);
                    }
                }

                break;
            }

            case Stat.Int:
            {
                if (CanRaise(from, Stat.Int, atTotalCap))
                {
                    if (atTotalCap)
                    {
                        if (CanLower(from, Stat.Str) && (from.RawStr < from.RawDex || !CanLower(from, Stat.Dex)))
                        {
                            --from.RawStr;
                        }
                        else if (CanLower(from, Stat.Dex))
                        {
                            --from.RawDex;
                        }
                    }

                    ++from.RawInt;

                    if (from is BaseCreature && ((BaseCreature)from).ManaMaxSeed > -1 && ((BaseCreature)from).ManaMaxSeed < from.IntCap)
                    {
                        ((BaseCreature)from).ManaMaxSeed++;
                    }

                    if (Siege.SiegeShard && from is PlayerMobile)
                    {
                        Siege.IncreaseStat((PlayerMobile)from);
                    }
                }

                break;
            }
            }
        }
Exemplo n.º 48
0
 private float GetBaseStat(Stat stat)
 {
     return(progression.GetStat(stat, characterClass, GetLevel()));
 }
Exemplo n.º 49
0
 public void MultiplyStat(Stat stat)
 {
     MultiplyStat(stat.Key, stat.Value);
 }
Exemplo n.º 50
0
 public float GetStat(Stat stat)
 {
     return((GetBaseStat(stat) + GetAdditiveModifier(stat)) * (1 + GetPercentageModifier(stat) / 100));
 }
Exemplo n.º 51
0
 public virtual void Add(Key key, Stat stat)
 {
     this._stats.Add(Pair.of(key, stat));
 }