Ejemplo n.º 1
0
        public void LaunchSpell(Fighter fighter, CharacterSpell spell, int cellID)
        {
            if (myState != FightState.PLAYING)
            {
                return;
            }

            Fighter firstTarget = GetAliveFighters().FirstOrDefault(x => x.Cell == cellID);
            int     targetID    = firstTarget == null ? -1 : firstTarget.ID;

            if (!CanLaunchSpell(fighter, spell, cellID, targetID))
            {
                return;
            }

            fighter.AP -= spell.LevelModel.Cost;

            bool isEchec = false;

            if (spell.LevelModel.EC != 0)
            {
                int echecRate = spell.LevelModel.EC - fighter.Stats.GetStat(StatEnum.EchecCritic).Total;

                if (echecRate < 2)
                {
                    echecRate = 2;
                }

                if (Basic.Rand(1, echecRate) == 1)
                {
                    isEchec = true;
                }
            }

            if (isEchec)
            {
                Send("GA;302;" + fighter.ID + ';' + spell.ID);
            }
            else
            {
                fighter.SpellController.OnLaunchSpell(spell, targetID);

                Send("GA;300;" + fighter.ID + ';' + spell.ID + ',' + cellID + ',' + spell.Model.Sprite + ',' + spell.Level + ',' + spell.Model.SpriteInfos);

                bool isCritic = false;

                if (spell.LevelModel.CC != 0 & spell.LevelModel.CriticalEffects.Count > 0)
                {
                    int criticRate = spell.LevelModel.CC - fighter.Stats.GetStat(StatEnum.DamageCritic).Total;

                    if (criticRate < 2)
                    {
                        criticRate = 2;
                    }

                    if (Basic.Rand(1, criticRate) == 1)
                    {
                        isCritic = true;
                    }
                }

                if (isCritic)
                {
                    Send("GA;301;" + fighter.ID + ';' + spell.ID);
                }

                List <EffectSpell> effects = isCritic ? spell.LevelModel.CriticalEffects : spell.LevelModel.Effects;
                List <Fighter>     targets = new List <Fighter>();

                foreach (int cell in CellZone.GetCells(myMap, cellID, fighter.Cell, spell.LevelModel.Type))
                {
                    Fighter target = GetAliveFighters().FirstOrDefault(x => x.Cell == cell);

                    if (target != null)
                    {
                        targets.Add(target);
                    }
                }

                int actualChance = 0;

                foreach (EffectSpell effect in effects)
                {
                    if (effect.Chance > 0)
                    {
                        if (Basic.Rand(1, 100) > effect.Chance + actualChance)
                        {
                            actualChance += effect.Chance;
                            continue;
                        }

                        actualChance -= 100;
                    }

                    targets.RemoveAll(x => x.Dead);

                    EffectProcessor.ApplyEffect(new EffectCast
                                                    ((EffectEnum)effect.ID, spell.ID, cellID, effect.Value, effect.Value2, effect.Value3, effect.Chance, effect.Round, (spell.LevelModel.MinRP == 1 & spell.LevelModel.MaxRP == 1), fighter, effect.Target.RemixTargets(fighter, targets)));
                }
            }

            Send("GA;102;" + fighter.ID + ';' + fighter.ID + ",-" + spell.LevelModel.Cost);

            if (GetWinners() != null)
            {
                FightEnd(GetWinners(), GetEnnemyTeam(GetWinners()));
            }
            else if (isEchec & spell.LevelModel.isECEndTurn)
            {
                TurnEnd();
            }
        }
Ejemplo n.º 2
0
 public abstract void PlayerLeave(Fighter fighter);
Ejemplo n.º 3
0
 public string FormatFightReady(Fighter fighter)
 {
     return(new StringBuilder("GR").Append(fighter.FightReady ? "1" : "0").Append(fighter.ID).ToString());
 }
Ejemplo n.º 4
0
        public void Toggle(Fighter fighter, ToggleType toggle)
        {
            if (!fighter.IsLeader)
            {
                return;
            }

            bool isToggle = !fighter.Team.IsToggle(toggle);

            fighter.Team.Toggle(toggle, isToggle);

            if (myState == FightState.STARTING)
            {
                myMap.Send(FormatFlagOption(toggle, fighter.Team));
            }

            switch (toggle)
            {
            case ToggleType.LOCK:
                if (isToggle)
                {
                    fighter.Team.Send("Im095");
                }
                else
                {
                    fighter.Team.Send("Im096");
                }
                break;

            case ToggleType.HELP:
                if (isToggle)
                {
                    fighter.Team.Send("Im0103");
                }
                else
                {
                    fighter.Team.Send("Im0104");
                }
                break;

            case ToggleType.PARTY:
                if (isToggle)
                {
                    KickNoParty(fighter.Team);
                    fighter.Team.Send("Im093");
                }
                else
                {
                    fighter.Team.Send("Im094");
                }
                break;

            case ToggleType.SPECTATOR:
                if (isToggle)
                {
                    KickSpectator();
                    fighter.Team.Send("Im040");
                }
                else
                {
                    fighter.Team.Send("Im039");
                }
                break;
            }
        }
Ejemplo n.º 5
0
 public string FormatPlace(Fighter fighter)
 {
     return(new StringBuilder("GIC|").Append(fighter.ID).Append(";").Append(fighter.Cell).Append(";1").ToString());
 }
Ejemplo n.º 6
0
 public string FormatFlagFighterDestroy(Fighter fighter)
 {
     return(new StringBuilder("Gt").Append(fighter.Team.Leader.ID).Append("|-").Append(fighter.ID).Append(";").Append(fighter.Name).Append(";").Append(fighter.Level).ToString());
 }
Ejemplo n.º 7
0
 public string FormatFighterDestroy(Fighter fighter)
 {
     return(new StringBuilder("GM|-").Append(fighter.ID).ToString());
 }
Ejemplo n.º 8
0
 public string FormatFighterShow(Fighter fighter)
 {
     return(new StringBuilder("GM|+").Append(fighter.GetPattern()).ToString());
 }
Ejemplo n.º 9
0
 public void FighterLeave(Fighter Fighter)
 {
     myFighters.Remove(Fighter);
 }