示例#1
0
 public CharacterFighter CreateFighter(FightTeam team)
 {
     Look.UnsetAura();
     RefreshOnMapInstance();
     Map.Instance.RemoveClient(Client);
     Client.Send(new GameContextDestroyMessage());
     Client.Send(new GameContextCreateMessage(2));
     Client.Send(new GameFightStartingMessage((sbyte)team.Fight.FightType, 0, 1));
     var fighter = new CharacterFighter(Client, team);
     FighterInstance = fighter;
     if (EquipedCompanion != null)
     {
         var cfighter = new CompanionFighter(EquipedCompanion, fighter, team);
         team.AddFighter(cfighter);
     }
     return fighter;
 }
示例#2
0
 public FightDual(MapRecord map, FightTeam blueTeam, FightTeam redTeam, short cellId)
     : base(map, blueTeam, redTeam, cellId)
 {
 }
 public FightPvM(int id, MapRecord map, FightTeam blueteam, FightTeam redteam, short fightcellid, MonsterGroup group)
     : base(id, map, blueteam, redteam, fightcellid)
 {
     this.MonsterGroup = group;
 }
示例#4
0
 public FightArena(MapRecord map, FightTeam blueTeam, FightTeam redTeam)
     : base(map, blueTeam, redTeam, 0)
 {
 }
示例#5
0
        public MonsterFighter AddSummon(Fighter master, short monsterid, sbyte grade, short cellid, FightTeam team)
        {
            MonsterFighter summoned = new MonsterFighter(MonsterRecord.GetMonster((ushort)monsterid),
              team, grade, cellid, master.ContextualId);
            if (summoned.Template.UseSummonSlot && !summoned.Template.UseBombSlot)
            TimeLine.Insert(summoned, master);
            Send(new GameActionFightSummonMessage(181, summoned.ContextualId, summoned.FighterInformations));
            Send(new GameFightTurnListMessage(TimeLine.GenerateTimeLine(false), new int[0]));
            return summoned;

        }
示例#6
0
        // TODO: Rewrite drops
        protected override IEnumerable <IFightResult> GenerateResults()
        {
            List <IFightResult> allFighters = new List <IFightResult>();

            allFighters.AddRange(from entry in this.GetAllFightersWithLeavers()
                                 where !(entry is IOwnable)
                                 select entry.GetFightResult());

            FightTeam[] teams = { this.BlueTeam, this.RedTeam };
            foreach (FightTeam team in teams)
            {
                int xpBonusPercent   = 0;
                int dropBonusPercent = 0;

                if (team == this.GetTeamChallenged())
                {
                    xpBonusPercent   += this.GetChallengesExpPercentBonus();
                    dropBonusPercent += this.GetChallengesDropPercentBonus();
                }

                FightTeam             enemyTeam   = team == this.RedTeam ? this.BlueTeam : this.RedTeam;
                IEnumerable <Fighter> deadEnemies = enemyTeam.GetDeads();

                // Retrieve the fighters who can loot, ordered by their pp (asc)
                List <IFightResult> looterFighters = allFighters.FindAll(x => x.CanLoot(team));
                IOrderedEnumerable <IFightResult> orderedLooters = looterFighters.OrderBy(x => x.Prospecting);

                List <Fighter> fighters = team.GetFighters(false);
                int            teamPP   = fighters.Sum(entry => entry.Stats.Prospecting.TotalInContext());
                teamPP += teamPP.GetPercentageOf(dropBonusPercent);

                // drops
                List <DroppedItem> teamLoots = new List <DroppedItem>();
                IEnumerable <DroppedItem> Selector(Fighter dropper) => dropper.RollLoot(teamPP, dropBonusPercent);

                foreach (DroppedItem current in deadEnemies.SelectMany(Selector))
                {
                    teamLoots.Add(current);
                }

                long baseKamas = deadEnemies.Sum(entry => (long)((ulong)entry.GetDroppedKamas()));
                using (IEnumerator <IFightResult> orderedLootersEnumerator = orderedLooters.GetEnumerator()) {
                    while (orderedLootersEnumerator.MoveNext())
                    {
                        IFightResult looter = orderedLootersEnumerator.Current;

                        // kamas
                        looter.Loot.Kamas = FormulasProvider.Instance.AdjustDroppedKamas(looter, teamPP, baseKamas, dropBonusPercent);

                        // Xp
                        if (looter is FightPlayerResult && looter.Outcome == FightOutcomeEnum.RESULT_VICTORY)
                        {
                            (looter as FightPlayerResult).AddEarnedExperience(xpBonusPercent);
                        }
                    }

                    // Distribution of loots :
                    if (teamLoots.Any())
                    {
                        AsyncRandom rand = new AsyncRandom();
                        // For each looted item...
                        foreach (DroppedItem item in teamLoots)
                        {
                            // We choose a random looter, but pp still has a little impact on the choice.
                            // For each player, we generate a random number between 0 and its max prospecting in context
                            // We sort the list in ascending order and get the last. We therefore get the fighter with the higher randomly generated number.
                            // Prospecting still has an impact since a player with higher pp has more chances to get a higher random number.
                            Fighter randomLooter = fighters.OrderBy(x => x.Stats.Prospecting.TotalInContext() * rand.NextDouble()).Last();

                            // Give the item looted by the team to this player.
                            randomLooter.Loot.AddItem(item);
                        }
                    }
                }
            }

            return(allFighters);
        }
示例#7
0
 public void SpawnBomb(Fighter master,short templateid,sbyte grade,short cellid,FightTeam team)
 {
     BombFighter bomb = new BombFighter(master,team,MonsterRecord.GetMonster((ushort)templateid),cellid,grade);
     Send(new GameActionFightSummonMessage(181,bomb.ContextualId,bomb.FighterInformations));
     bomb.CheckWalls();
 }
示例#8
0
 public void UpdateTeam(FightTeam team)
 {
     Send(new GameFightUpdateTeamMessage((short)Id, team.GetFightTeamInformations()));
 }
示例#9
0
 public FightInstancePvM(MapRecord map, FightTeam blueTeam, FightTeam redTeam, MonsterRecord[] templates)
     : base(map, blueTeam, redTeam, 0, MonsterGroup.FromTemplates(map, templates))
 {
 }
示例#10
0
 public FightDual(int id, MapRecord map, FightTeam blueteam, FightTeam redteam, short fightcellid, short secondplayercellid) : base(id, map, blueteam, redteam, fightcellid)
 {
     this.SecondFighterCellId = secondplayercellid;
 }
示例#11
0
 public FreeFightInstancePvM(MapRecord map, FightTeam blueTeam, FightTeam redTeam, MonsterRecord[] templates)
     : base(map, blueTeam, redTeam, templates)
 {
 }