public static List<Models.CharacterModel> getCurrentParty(PlayerModel pm, List<int> characterUniqs = null)
        {
            if (characterUniqs == null)
            {
                characterUniqs = new List<int>();
                List<Models.PartyCharacterModel> partyCharacters = getCurrentPartyPartyStats(pm);
                foreach (Models.PartyCharacterModel pcm in partyCharacters)
                {
                    characterUniqs.Add(pcm.characterUniq);
                }
            }

            List<Models.CharacterModel> returnValues = new List<Models.CharacterModel>();
            foreach(int characterUniq in characterUniqs)
            {
                foreach (Models.CharacterModel cm in pm.characters)
                {
                    if (cm.uniq == characterUniq)
                    {
                        returnValues.Add(cm);
                    }
                }
            }
            return returnValues;
        }
 public static List<string> getClasses(PlayerModel pm)
 {
     List<string> classes = new List<string>();
     classes.Add("Adventurer");
     if(pm.isObjectiveCompleted(ObjectiveType.Brawler))
     {
         classes.Add("Brawler");
     }
     classes.Add("Mage");
     return classes;
 }
 public void copyTo(PlayerModel pm)
 {
     pm.rootMap = rootMap;
     pm.rootX = rootX;
     pm.rootY = rootY;
     pm.items = items;
     pm.gp = gp;
     pm.characters = characters;
     pm.parties = parties;
     pm.activeParty = activeParty;
     pm.configuration = configuration;
     pm.objectives = objectives;
 }
 public static void addCharacter(PlayerModel pm)
 {
     Models.CharacterModel cm = new Models.CharacterModel();
     cm.name = "Alexander";
     cm.currentClass = "Adventurer";
     cm.lvl = 1;
     cm.activeAbilities = new List<Models.CharacterAbilityModel>();
     cm.characterClasses = new List<Models.CharacterClassModel>();
     cm.characterClasses.Add(new Models.CharacterClassModel() { className = "Adventurer", cp = 0, lvl = 1 });
     cm.currentQuest = new Models.CharacterQuestModel();
     cm.equipment = new Models.EquipmentModel() { accessory = "", armor = "", weapon = "" };
     cm.stats = new Models.StatsModel() { maxHP = 25, maxMP = 1, strength = 5, vitality = 5, intellect = 5, wisdom = 5, agility = 5 };
     StatCalculations.StatCalculator.updateCharacterStats(cm);
     pm.characters.Add(cm);
 }
        public static List<CombatDataModels.CombatCharacterModel> getCurrentPartyCombatStats(PlayerModel pm, List<int> characterUniqs = null)
        {
            if (characterUniqs == null)
            {
                characterUniqs = new List<int>();
                List<Models.PartyCharacterModel> partyCharacters = getCurrentPartyPartyStats(pm);
                foreach (Models.PartyCharacterModel pcm in partyCharacters)
                {
                    characterUniqs.Add(pcm.characterUniq);
                }
            }

            List<CombatDataModels.CombatCharacterModel> returnValues = new List<CombatDataModels.CombatCharacterModel>();

            foreach (int i in characterUniqs)
            {
                foreach (CombatDataModels.CombatCharacterModel cpm in pm.currentCombat.pcs)
                {
                    if (cpm.characterUniq == i)
                    {
                        returnValues.Add(cpm);
                    }
                }
            }

            return returnValues;
        }
 public static void processEvent(MapEventModel currentEvent, PlayerModel player, ref List<ClientMessage> messageQueue)
 {
     switch (currentEvent.rewardType)
     {
         case MapDataClasses.ClientEvent.RewardType.Objective:
             string returnValue = ObjectiveDirector.completeObjective(player, currentEvent.eventData.objective);
             if (returnValue != string.Empty)
             {
                 messageQueue.Add(new ClientMessage()
                 {
                     message = returnValue,
                     type = ClientMessage.ClientMessageType.Message
                 });
                 messageQueue.Add(new ClientMessage()
                 {
                     type = ClientMessage.ClientMessageType.RefreshMap
                 });
             }
             break;
         case MapDataClasses.ClientEvent.RewardType.XP:
             messageQueue.Add(new ClientMessage()
             {
                 message = "All characters have gained " + currentEvent.rewardValue.ToString() + " XP!",
                 type = ClientMessage.ClientMessageType.Message
             });
             messageQueue.Add(new ClientMessage()
             {
                 type = ClientMessage.ClientMessageType.RefreshMap
             });
             List<string> results = PlayerDataManager.givePartyXP(player, currentEvent.rewardValue);
             foreach (string s in results)
             {
                 messageQueue.Add(new ClientMessage()
                 {
                     message = s
                 });
             }
             break;
         case MapDataClasses.ClientEvent.RewardType.CP:
             messageQueue.Add(new ClientMessage()
             {
                 message = "All characters have gained " + currentEvent.rewardValue.ToString() + " CP!",
                 type = ClientMessage.ClientMessageType.Message
             });
             messageQueue.Add(new ClientMessage()
             {
                 type = ClientMessage.ClientMessageType.RefreshMap
             });
             List<string> cpResults = PlayerDataManager.givePartyCP(player, currentEvent.rewardValue);
             foreach (string s in cpResults)
             {
                 messageQueue.Add(new ClientMessage()
                 {
                     message = s
                 });
             }
             break;
         case MapDataClasses.ClientEvent.RewardType.Gold:
             messageQueue.Add(new ClientMessage()
             {
                 message = "You have found " + currentEvent.rewardValue.ToString() + " GP!",
                 type = ClientMessage.ClientMessageType.Message
             });
             messageQueue.Add(new ClientMessage()
             {
                 type = ClientMessage.ClientMessageType.RefreshMap
             });
             PlayerDataManager.givePartyGP(player, currentEvent.rewardValue);
             break;
     }
     player.getActiveParty().location.eventCollection.removeEvent(currentEvent);
     player.getActiveParty().location.activeEvent = null;
 }
 public static PlayerModel initPlayerModel()
 {
     PlayerModel returnValue = new PlayerModel();
     returnValue.characters = new List<Models.CharacterModel>();
     Models.CharacterModel cm = new Models.CharacterModel();
     cm.name = "Alex";
     cm.currentClass = "Adventurer";
     cm.lvl = 1;
     cm.activeAbilities = new List<Models.CharacterAbilityModel>();
     cm.characterClasses = new List<Models.CharacterClassModel>();
     cm.characterClasses.Add(new Models.CharacterClassModel() { className = "Adventurer", cp = 0, lvl = 1 });
     cm.characterClasses.Add(new Models.CharacterClassModel() { className = "Brawler", cp = 0, lvl = 1 });
     cm.currentQuest = new Models.CharacterQuestModel();
     cm.equipment = new Models.EquipmentModel() { accessory = "", armor = "", weapon = "" };
     cm.stats = new Models.StatsModel() { maxHP = 25, maxMP = 1, strength = 5, vitality = 5, intellect = 5, wisdom = 5, agility = 5 };
     returnValue.characters.Add(cm);
     cm = new Models.CharacterModel();
     cm.name = "Noright";
     cm.currentClass = "Brawler";
     cm.lvl = 1;
     cm.activeAbilities = new List<Models.CharacterAbilityModel>();
     cm.characterClasses = new List<Models.CharacterClassModel>();
     cm.characterClasses.Add(new Models.CharacterClassModel() { className = "Adventurer", cp = 0, lvl = 1 });
     cm.characterClasses.Add(new Models.CharacterClassModel() { className = "Brawler", cp = 0, lvl = 1 });
     cm.currentQuest = new Models.CharacterQuestModel();
     cm.equipment = new Models.EquipmentModel() { accessory = "", armor = "", weapon = "" };
     cm.stats = new Models.StatsModel() { maxHP = 25, maxMP = 1, strength = 5, vitality = 5, intellect = 5, wisdom = 5, agility = 5 };
     returnValue.characters.Add(cm);
     cm = new CharacterModel();
     cm.name = "Centers";
     cm.currentClass = "Mage";
     cm.lvl = 1;
     cm.activeAbilities = new List<Models.CharacterAbilityModel>();
     cm.characterClasses = new List<Models.CharacterClassModel>();
     cm.characterClasses.Add(new Models.CharacterClassModel() { className = "Adventurer", cp = 0, lvl = 1 });
     cm.characterClasses.Add(new Models.CharacterClassModel() { className = "Brawler", cp = 0, lvl = 1 });
     cm.characterClasses.Add(new Models.CharacterClassModel() { className = "Mage", cp = 0, lvl = 1 });
     cm.currentQuest = new Models.CharacterQuestModel();
     cm.equipment = new Models.EquipmentModel() { accessory = "", armor = "", weapon = "" };
     cm.stats = new Models.StatsModel() { maxHP = 25, maxMP = 1, strength = 5, vitality = 5, intellect = 5, wisdom = 5, agility = 5 };
     returnValue.characters.Add(cm);
     returnValue.configuration = new List<Models.ConfigurationModel>();
     returnValue.gp = 0;
     returnValue.items = new List<Models.PlayerItemModel>();
     returnValue.parties = new List<Models.PartyModel>();
     returnValue.rootMap = "Ensemble Village";
     returnValue.rootX = 5;
     returnValue.rootY = 5;
     return returnValue;
 }
        public static List<string> giveXPCP(PlayerModel playerModel, int characterUniq, int xp, int cp)
        {
            List<string> results = new List<string>();

            foreach (CharacterModel cm in playerModel.characters)
            {
                if (cm.uniq == characterUniq)
                {
                    cm.xp += xp;
                    while (cm.xp >= PlayerModels.PlayerDataManager.getXPForLevel(cm.lvl))
                    {
                        results.Add(cm.name + " has gained a level!");
                        cm.lvl++;
                        PlayerModels.StatCalculations.StatCalculator.updateCharacterStats(cm);
                    }
                    foreach (CharacterClassModel ccm in cm.characterClasses)
                    {
                        if (ccm.className == cm.currentClass)
                        {
                            ccm.cp += cp;
                            while (ccm.cp >= PlayerModels.PlayerDataManager.getCPForLevel(ccm.lvl))
                            {
                                results.Add(cm.name + " has gained a class level!");
                                ccm.lvl++;
                                PlayerModels.StatCalculations.StatCalculator.updateCharacterStats(cm);

                                string newAbilityMessage = PlayerModels.StatCalculations.StatCalculator.getNewAbilityText(cm);
                                if (newAbilityMessage != string.Empty)
                                {
                                    results.Add(newAbilityMessage);
                                }
                            }
                        }
                    }
                }
            }

            return results;
        }
        public static List<string> givePartyXP(PlayerModel pm, int xp)
        {
            List<int> partyUniqs = new List<int>();
            PartyModel currentParty = pm.getActiveParty();
            List<string> results = new List<string>();
            foreach (PartyCharacterModel pcm in currentParty.characters)
            {
                results.AddRange(giveXPCP(pm, pcm.characterUniq, xp, 0));
            }

            return results;
        }
 public static void givePartyGP(PlayerModel pm, int gp)
 {
     pm.gp += gp;
 }
        public static List<Models.CharacterModel> getInactiveCharacters(PlayerModel pm)
        {
            bool canAdd = true;
            List<Models.CharacterModel> returnValues = new List<Models.CharacterModel>();
            foreach (Models.CharacterModel cm in pm.characters)
            {
                foreach (Models.PartyModel party in pm.parties)
                {
                    foreach (Models.PartyCharacterModel pcm in party.characters)
                    {
                        if (pcm.uniq == cm.uniq)
                        {
                            canAdd = false;
                        }
                    }
                }

                if (canAdd)
                {
                    returnValues.Add(cm);
                }
            }

            return returnValues;
        }
        public static List<Models.PartyCharacterModel> getCurrentPartyPartyStats(PlayerModel pm)
        {
            List<Models.PartyCharacterModel> returnValues = new List<Models.PartyCharacterModel>();

            foreach(Models.PartyModel partyModels in pm.parties)
            {
                if(partyModels.uniq == pm.activeParty)
                {
                    foreach(PlayerModels.Models.PartyCharacterModel pcm in partyModels.characters)
                    {
                        returnValues.Add(pcm);
                    }
                }
            }

            return returnValues;
        }
Esempio n. 13
0
        public Combat(PlayerModels.PlayerModel playerModel, string map, int encounterSelection, Func <float> initiativeCalculator, Action onGameOver, Action onUpdate, Action <CombatEndType> onCombatComplete)
        {
            int currentUniq = 1;

            this.playerModel = playerModel;
            uniqBridge       = new Dictionary <int, int>();
            pcs                   = new Dictionary <int, FullCombatCharacter>();
            npcs                  = new Dictionary <int, FullCombatCharacter>();
            currentEffects        = new List <IEffect>();
            currentCharacter      = new FullCombatCharacter();
            this.onGameOver       = onGameOver;
            this.onUpdate         = onUpdate;
            this.onCombatComplete = onCombatComplete;
            this.map              = map;
            bool canFlee = true;

            List <PlayerModels.Models.PartyCharacterModel> partyCharacterModels = PlayerModels.PlayerDataManager.getCurrentPartyPartyStats(playerModel);
            List <int> characterUniqs = new List <int>();

            foreach (PlayerModels.Models.PartyCharacterModel pcm in partyCharacterModels)
            {
                characterUniqs.Add(pcm.characterUniq);
            }
            List <PlayerModels.Models.CharacterModel> characterModels = PlayerModels.PlayerDataManager.getCurrentParty(playerModel, characterUniqs);
            bool hasPreviousCombatModels = false;

            if (playerModel.currentCombat == null)
            {
                combatCharacterModels                 = new List <PlayerModels.CombatDataModels.CombatCharacterModel>();
                combatNPCModels                       = new List <CombatCharacterModel>();
                playerModel.currentCombat             = new CombatModel();
                playerModel.currentCombat.currentTime = 0;
                playerModel.currentCombat.pcs         = combatCharacterModels;
                playerModel.currentCombat.npcs        = combatNPCModels;
            }
            else
            {
                combatCharacterModels   = playerModel.currentCombat.pcs;
                combatNPCModels         = playerModel.currentCombat.npcs;
                hasPreviousCombatModels = true;
            }

            foreach (int characterUniq in characterUniqs)
            {
                string name           = string.Empty;
                int    hp             = 0;
                int    maxHP          = 0;
                int    mp             = 0;
                int    maxMP          = 0;
                int    turnOrder      = 0;
                string classType      = string.Empty;
                int    level          = 0;
                int    strength       = 0;
                int    vitality       = 0;
                int    agility        = 0;
                int    intellect      = 0;
                int    wisdom         = 0;
                int    nextAttackTime = 0;
                int    classLevel     = 0;
                int    combatUniq     = currentUniq;
                List <CombatModificationsModel> mods = new List <CombatModificationsModel>();
                List <string> usedAbilities          = new List <string>();
                uniqBridge.Add(currentUniq, characterUniq);

                foreach (PlayerModels.Models.CharacterModel cm in characterModels)
                {
                    if (cm.uniq == characterUniq)
                    {
                        name      = cm.name;
                        maxHP     = cm.stats.maxHP;
                        maxMP     = cm.stats.maxMP;
                        classType = cm.currentClass;
                        level     = cm.lvl;
                        strength  = cm.stats.strength;
                        vitality  = cm.stats.vitality;
                        agility   = cm.stats.agility;
                        intellect = cm.stats.intellect;
                        wisdom    = cm.stats.wisdom;

                        foreach (PlayerModels.Models.CharacterClassModel ccm in cm.characterClasses)
                        {
                            if (ccm.className == classType)
                            {
                                classLevel = ccm.lvl;
                            }
                        }
                    }
                }

                foreach (PlayerModels.Models.PartyCharacterModel pcm in partyCharacterModels)
                {
                    if (pcm.characterUniq == characterUniq)
                    {
                        hp            = pcm.hp;
                        mp            = pcm.mp;
                        usedAbilities = (pcm.usedAbilities == null ? new List <string>() : pcm.usedAbilities);
                    }
                }

                nextAttackTime = GeneralProcessor.calculateNextAttackTime(0, initiativeCalculator(), agility);

                if (hasPreviousCombatModels)
                {
                    foreach (CombatCharacterModel ccm in combatCharacterModels)
                    {
                        if (ccm.characterUniq == characterUniq)
                        {
                            nextAttackTime = ccm.nextAttackTime;
                            hp             = ccm.stats.hp;
                            mp             = ccm.stats.mp;
                            combatUniq     = ccm.combatUniq;
                        }
                    }
                }
                else
                {
                    combatCharacterModels.Add(new PlayerModels.CombatDataModels.CombatCharacterModel()
                    {
                        characterUniq = characterUniq,
                        stats         = new PlayerModels.CombatDataModels.TemporaryCombatStatsModel()
                        {
                            hp = hp, mp = mp
                        },
                        nextAttackTime = nextAttackTime,
                        combatUniq     = combatUniq
                    });
                }

                pcs.Add(characterUniq, new FullCombatCharacter()
                {
                    name           = name,
                    maxHP          = maxHP,
                    hp             = hp,
                    maxMP          = maxMP,
                    mp             = mp,
                    characterUniq  = characterUniq,
                    combatUniq     = currentUniq,
                    className      = classType,
                    classLevel     = classLevel,
                    level          = level,
                    strength       = strength,
                    vitality       = vitality,
                    intellect      = intellect,
                    agility        = agility,
                    wisdom         = wisdom,
                    nextAttackTime = nextAttackTime,
                    mods           = new List <CombatModificationsModel>(),
                    usedAbilities  = usedAbilities
                });

                combatCharacterModels[combatCharacterModels.Count - 1].mods = pcs[characterUniq].mods;

                currentUniq++;
            }

            if (hasPreviousCombatModels) //Combat was already initialized previously, just load the previous combatants
            {
                foreach (CombatCharacterModel ccm in combatNPCModels)
                {
                    int    hp             = ccm.stats.hp;
                    int    mp             = ccm.stats.mp;
                    string name           = ccm.name;
                    int    nextAttackTime = ccm.nextAttackTime;
                    List <CombatModificationsModel> mods = ccm.mods;
                    List <string> usedAbilities          = new List <string>();

                    MapDataClasses.MapDataClasses.Enemy enemy = MapDataClasses.MapDataManager.getEnemy(map, ccm.classType);

                    if (!this.npcs.ContainsKey(currentUniq))
                    {
                        this.npcs.Add(currentUniq, new FullCombatCharacter()
                        {
                            name           = name,
                            hp             = hp,
                            maxHP          = enemy.maxHP,
                            mp             = mp,
                            maxMP          = enemy.maxMP,
                            characterUniq  = 0,
                            combatUniq     = currentUniq,
                            className      = enemy.type,
                            level          = enemy.level,
                            strength       = enemy.strength,
                            vitality       = enemy.vitality,
                            agility        = enemy.agility,
                            intellect      = enemy.intellect,
                            wisdom         = enemy.wisdom,
                            nextAttackTime = nextAttackTime,
                            mods           = mods,
                            usedAbilities  = usedAbilities
                        });
                    }

                    currentUniq++;
                }
            }
            else //Generate a new encounter based on the map type
            {
                Encounter encounter = MapDataClasses.MapDataManager.getEncounter(this.playerModel.getActiveParty().location, playerModel.rootX, playerModel.rootY, encounterSelection);
                currentEffects.Add(new Effect(EffectTypes.Message, 0, encounter.message, 0));
                combatNPCModels = new List <PlayerModels.CombatDataModels.CombatCharacterModel>();
                canFlee         = encounter.canFlee;
                foreach (MapDataClasses.MapDataClasses.Enemy enemy in encounter.enemies)
                {
                    int nextAttackTime = GeneralProcessor.calculateNextAttackTime(0, initiativeCalculator(), enemy.agility);
                    int hp             = enemy.maxHP;
                    int mp             = enemy.maxMP;
                    int combatUniq     = currentUniq;
                    List <CombatModificationsModel> mods = new List <CombatModificationsModel>();
                    List <string> usedAbilities          = new List <string>();

                    this.npcs.Add(currentUniq, new FullCombatCharacter()
                    {
                        name           = enemy.name,
                        hp             = hp,
                        maxHP          = enemy.maxHP,
                        mp             = mp,
                        maxMP          = enemy.maxMP,
                        characterUniq  = 0,
                        combatUniq     = currentUniq,
                        className      = enemy.type,
                        level          = enemy.level,
                        strength       = enemy.strength,
                        vitality       = enemy.vitality,
                        agility        = enemy.agility,
                        intellect      = enemy.intellect,
                        wisdom         = enemy.wisdom,
                        nextAttackTime = nextAttackTime,
                        mods           = mods,
                        usedAbilities  = usedAbilities
                    });


                    this.combatNPCModels.Add(new PlayerModels.CombatDataModels.CombatCharacterModel()
                    {
                        name  = enemy.name,
                        stats = new PlayerModels.CombatDataModels.TemporaryCombatStatsModel()
                        {
                            hp = hp,
                            mp = mp
                        },
                        nextAttackTime = nextAttackTime,
                        combatUniq     = currentUniq,
                        characterUniq  = 0,
                        classType      = enemy.type,
                        mods           = this.npcs[currentUniq].mods
                    });

                    currentUniq++;
                }
            }

            playerModel.currentCombat.npcs = combatNPCModels;
            if (combatNPCModels.Count == 0)
            {
                throw new Exception("No NPCs were loaded :(");
            }

            calculateTurnOrder();
            this.combatData = new CombatData(playerModel.currentCombat, canFlee);

            if (!this.combatData.combatInitalized)
            {
                foreach (int key in pcs.Keys) //Check for initial code
                {
                    FullCombatCharacter fcc        = pcs[key];
                    List <IEffect>      newEffects = GeneralProcessor.initialExecute(fcc)(getAllPcsAsList(), getAllNpcsAsList(), this.combatData);
                    currentEffects.AddRange(newEffects);
                }

                this.combatData.combatInitalized = true;
            }
            calculateTurn(false);
        }
Esempio n. 14
0
        public Combat(PlayerModels.PlayerModel playerModel, string map, int encounterSelection, Func<float> initiativeCalculator, Action onGameOver, Action onUpdate, Action<CombatEndType> onCombatComplete)
        {
            int currentUniq = 1;
            this.playerModel = playerModel;
            uniqBridge = new Dictionary<int, int>();
            pcs = new Dictionary<int, FullCombatCharacter>();
            npcs = new Dictionary<int, FullCombatCharacter>();
            currentEffects = new List<IEffect>();
            currentCharacter = new FullCombatCharacter();
            this.onGameOver = onGameOver;
            this.onUpdate = onUpdate;
            this.onCombatComplete = onCombatComplete;
            this.map = map;
            bool canFlee = true;

            List<PlayerModels.Models.PartyCharacterModel> partyCharacterModels = PlayerModels.PlayerDataManager.getCurrentPartyPartyStats(playerModel);
            List<int> characterUniqs = new List<int>();
            foreach (PlayerModels.Models.PartyCharacterModel pcm in partyCharacterModels)
            {
                characterUniqs.Add(pcm.characterUniq);
            }
            List<PlayerModels.Models.CharacterModel> characterModels = PlayerModels.PlayerDataManager.getCurrentParty(playerModel, characterUniqs);
            bool hasPreviousCombatModels = false;
            if (playerModel.currentCombat == null)
            {
                combatCharacterModels = new List<PlayerModels.CombatDataModels.CombatCharacterModel>();
                combatNPCModels = new List<CombatCharacterModel>();
                playerModel.currentCombat = new CombatModel();
                playerModel.currentCombat.currentTime = 0;
                playerModel.currentCombat.pcs = combatCharacterModels;
                playerModel.currentCombat.npcs = combatNPCModels;
            }
            else
            {
                combatCharacterModels = playerModel.currentCombat.pcs;
                combatNPCModels = playerModel.currentCombat.npcs;
                hasPreviousCombatModels = true;
            }

            foreach (int characterUniq in characterUniqs)
            {
                string name = string.Empty;
                int hp = 0;
                int maxHP = 0;
                int mp = 0;
                int maxMP = 0;
                int turnOrder = 0;
                string classType = string.Empty;
                int level = 0;
                int strength = 0;
                int vitality = 0;
                int agility = 0;
                int intellect = 0;
                int wisdom = 0;
                int nextAttackTime = 0;
                int classLevel = 0;
                int combatUniq = currentUniq;
                List<CombatModificationsModel> mods = new List<CombatModificationsModel>();
                List<string> usedAbilities = new List<string>();
                uniqBridge.Add(currentUniq, characterUniq);

                foreach (PlayerModels.Models.CharacterModel cm in characterModels)
                {
                    if (cm.uniq == characterUniq)
                    {
                        name = cm.name;
                        maxHP = cm.stats.maxHP;
                        maxMP = cm.stats.maxMP;
                        classType = cm.currentClass;
                        level = cm.lvl;
                        strength = cm.stats.strength;
                        vitality = cm.stats.vitality;
                        agility = cm.stats.agility;
                        intellect = cm.stats.intellect;
                        wisdom = cm.stats.wisdom;

                        foreach (PlayerModels.Models.CharacterClassModel ccm in cm.characterClasses)
                        {
                            if (ccm.className == classType)
                            {
                                classLevel = ccm.lvl;
                            }
                        }
                    }
                }

                foreach (PlayerModels.Models.PartyCharacterModel pcm in partyCharacterModels)
                {
                    if (pcm.characterUniq == characterUniq)
                    {
                        hp = pcm.hp;
                        mp = pcm.mp;
                        usedAbilities = (pcm.usedAbilities == null ? new List<string>() : pcm.usedAbilities);
                    }
                }

                nextAttackTime = GeneralProcessor.calculateNextAttackTime(0, initiativeCalculator(), agility);

                if (hasPreviousCombatModels)
                {
                    foreach (CombatCharacterModel ccm in combatCharacterModels)
                    {
                        if (ccm.characterUniq == characterUniq)
                        {
                            nextAttackTime = ccm.nextAttackTime;
                            hp = ccm.stats.hp;
                            mp = ccm.stats.mp;
                            combatUniq = ccm.combatUniq;
                        }
                    }
                }
                else {
                    combatCharacterModels.Add(new PlayerModels.CombatDataModels.CombatCharacterModel()
                    {
                        characterUniq = characterUniq,
                        stats = new PlayerModels.CombatDataModels.TemporaryCombatStatsModel() { hp = hp, mp = mp },
                        nextAttackTime = nextAttackTime,
                        combatUniq = combatUniq
                    });
                }

                pcs.Add(characterUniq, new FullCombatCharacter() {
                   name = name,
                   maxHP = maxHP,
                   hp =  hp,
                   maxMP = maxMP,
                   mp = mp,
                   characterUniq = characterUniq,
                   combatUniq = currentUniq,
                   className = classType,
                   classLevel = classLevel,
                   level = level,
                   strength = strength,
                   vitality = vitality,
                   intellect = intellect,
                   agility = agility,
                   wisdom = wisdom,
                   nextAttackTime = nextAttackTime,
                   mods = new List<CombatModificationsModel>(),
                   usedAbilities = usedAbilities
                });

                combatCharacterModels[combatCharacterModels.Count - 1].mods = pcs[characterUniq].mods;

                currentUniq++;
            }

            if (hasPreviousCombatModels) //Combat was already initialized previously, just load the previous combatants
            {
                foreach (CombatCharacterModel ccm in combatNPCModels)
                {
                    int hp = ccm.stats.hp;
                    int mp = ccm.stats.mp;
                    string name = ccm.name;
                    int nextAttackTime = ccm.nextAttackTime;
                    List<CombatModificationsModel> mods = ccm.mods;
                    List<string> usedAbilities = new List<string>();

                    MapDataClasses.MapDataClasses.Enemy enemy = MapDataClasses.MapDataManager.getEnemy(map, ccm.classType);

                    if (!this.npcs.ContainsKey(currentUniq))
                    {
                        this.npcs.Add(currentUniq, new FullCombatCharacter()
                        {
                            name = name,
                            hp = hp,
                            maxHP = enemy.maxHP,
                            mp = mp,
                            maxMP = enemy.maxMP,
                            characterUniq = 0,
                            combatUniq = currentUniq,
                            className = enemy.type,
                            level = enemy.level,
                            strength = enemy.strength,
                            vitality = enemy.vitality,
                            agility = enemy.agility,
                            intellect = enemy.intellect,
                            wisdom = enemy.wisdom,
                            nextAttackTime = nextAttackTime,
                            mods = mods,
                            usedAbilities = usedAbilities
                        });
                    }

                    currentUniq++;
                }
            }
            else //Generate a new encounter based on the map type
            {
                Encounter encounter = MapDataClasses.MapDataManager.getEncounter(this.playerModel.getActiveParty().location, playerModel.rootX, playerModel.rootY, encounterSelection);
                currentEffects.Add(new Effect(EffectTypes.Message, 0, encounter.message, 0));
                combatNPCModels = new List<PlayerModels.CombatDataModels.CombatCharacterModel>();
                canFlee = encounter.canFlee;
                foreach (MapDataClasses.MapDataClasses.Enemy enemy in encounter.enemies)
                {
                    int nextAttackTime = GeneralProcessor.calculateNextAttackTime(0, initiativeCalculator(), enemy.agility);
                    int hp = enemy.maxHP;
                    int mp = enemy.maxMP;
                    int combatUniq = currentUniq;
                    List<CombatModificationsModel> mods = new List<CombatModificationsModel>();
                    List<string> usedAbilities = new List<string>();

                    this.npcs.Add(currentUniq, new FullCombatCharacter()
                    {
                        name = enemy.name,
                        hp = hp,
                        maxHP = enemy.maxHP,
                        mp = mp,
                        maxMP = enemy.maxMP,
                        characterUniq = 0,
                        combatUniq = currentUniq,
                        className = enemy.type,
                        level = enemy.level,
                        strength = enemy.strength,
                        vitality = enemy.vitality,
                        agility = enemy.agility,
                        intellect = enemy.intellect,
                        wisdom = enemy.wisdom,
                        nextAttackTime = nextAttackTime,
                        mods = mods,
                        usedAbilities = usedAbilities
                    });

                    this.combatNPCModels.Add(new PlayerModels.CombatDataModels.CombatCharacterModel()
                    {
                        name = enemy.name,
                        stats = new PlayerModels.CombatDataModels.TemporaryCombatStatsModel()
                        {
                            hp = hp,
                            mp = mp
                        },
                        nextAttackTime = nextAttackTime,
                        combatUniq = currentUniq,
                        characterUniq = 0,
                        classType = enemy.type,
                        mods = this.npcs[currentUniq].mods
                    });

                    currentUniq++;
                }
            }

            playerModel.currentCombat.npcs = combatNPCModels;
            if (combatNPCModels.Count == 0)
            {
                throw new Exception("No NPCs were loaded :(");
            }

            calculateTurnOrder();
            this.combatData = new CombatData(playerModel.currentCombat, canFlee);

            if (!this.combatData.combatInitalized)
            {
                foreach (int key in pcs.Keys) //Check for initial code
                {
                    FullCombatCharacter fcc = pcs[key];
                    List<IEffect> newEffects = GeneralProcessor.initialExecute(fcc)(getAllPcsAsList(), getAllNpcsAsList(), this.combatData);
                    currentEffects.AddRange(newEffects);
                }

                this.combatData.combatInitalized = true;
            }
            calculateTurn(false);
        }