예제 #1
0
        //renew the detail of the allies
        private void setPlayersData()
        {
            allies            = new Allies();
            playersHeroName   = new Dictionary <String, String>();
            playersHeroHPInfo = new Dictionary <String, String>();
            int index = 0;

            foreach (var client in clients)
            {
                String name = client.Key;
                int    heroID;
                String heroName   = "Selecting Hero...";
                String heroHPInfo = "";
                if (players.Keys.Contains(client.Key))
                {
                    heroID     = playerSelectedHero[name];
                    heroName   = heroInfo.Heroes[heroID].heroName;
                    heroHPInfo = selectedHeroHP[name] + " / " + heroInfo.Heroes[heroID].healthPoints;
                }
                Ally ally = new Ally(name, heroName, heroHPInfo);
                allies.alliesList.Insert(index, ally);
                playersHeroName.Add(name, heroName);
                playersHeroHPInfo.Add(name, heroHPInfo);
                index++;
            }
        }
예제 #2
0
        //calculate player round
        public Boolean calPlayerRound(HeroInfo heroInfo, Allies allies, Boss boss)
        {
            int playersTotalDamage = 0;

            foreach (var player in playerSelectedHero)
            {
                String name           = player.Key;
                int    heroID         = playerSelectedHero[name];
                int    heroMaxHP      = heroInfo.Heroes[heroID].healthPoints;
                int    abilityID      = playerSelectedAbility[name];
                int    selectTargetID = playerSelectedTarget[name];
                if (abilityID != -1)
                {
                    int abilityValue       = heroInfo.Heroes[heroID].abilityList[abilityID].value;
                    int abilityActualValue = calHeroActualValue(abilityValue);

                    String abilityType   = heroInfo.Heroes[heroID].abilityList[abilityID].type;
                    String abilityTarget = heroInfo.Heroes[heroID].abilityList[abilityID].target;

                    //if Damage boss
                    if (abilityType == "D")
                    {
                        playersTotalDamage += abilityActualValue;
                        playersDamage.Add(player.Key, abilityActualValue);
                    }
                    else
                    {
                        //if Heal a single ally
                        if (abilityTarget == "S")
                        {
                            if (selectTargetID != -1)
                            {
                                String target = allies.alliesList[selectTargetID].name;
                                if (alivesList.Contains(target))
                                {
                                    heal(target, heroInfo, abilityActualValue);
                                }
                            }
                        }
                        else//if  heal all allies
                        {
                            foreach (var alive in alivesList)
                            {
                                heal(alive, heroInfo, abilityActualValue);
                            }
                        }
                    }
                }
            }
            //calculate current HP of boss
            if (playersTotalDamage > boss.defence)
            {
                bossCurrentHP -= (playersTotalDamage - boss.defence);
            }

            //if boss is died
            if (bossCurrentHP <= 0)
            {
                return(true);
            }

            return(false);
        }