示例#1
0
文件: Hero.cs 项目: palome06/psd48
        public HeroLib()
        {
            dicts = new Dictionary<int, Hero>();
            sql = new Utils.ReadonlySQL("psd.db3");
            List<string> list = new string[] {
                "ID", "GENRE", "VALID", "OFCODE", "NAME", "HP", "STR", "DEX",
                "GENDER", "SPOUSE", "ISO", "SKILL", "ALIAS", "BIO"
            }.ToList();
            System.Data.DataRowCollection datas = sql.Query(list, "Hero");
            foreach (System.Data.DataRow data in datas)
            {
                string gs = (string)data["VALID"];
                int group = int.Parse(gs.Contains(",") ? gs.Substring(0, gs.IndexOf(',')) : gs);

                int genre = (int)((long)data["GENRE"]);
                int code = (int)((long)data["ID"]);
                string name = (string)data["NAME"];
                ushort hp = (ushort)((short)data["HP"]);
                ushort str = (ushort)((short)data["STR"]);
                ushort dex = (ushort)((short)data["DEX"]);
                char gender = ((string)data["GENDER"])[0];
                string spouses = (string)data["SPOUSE"];
                List<string> spouse = string.IsNullOrEmpty(spouses) ?
                    new List<string>() : spouses.Split(',').ToList();
                string isoStr = (string)data["ISO"];
                int archetype = 0, antecessor = 0;
                List<int> isos = new List<int>();
                foreach (string isosr in isoStr.Split(','))
                {
                    if (isosr.StartsWith("@"))
                        archetype = int.Parse(isosr.Substring("@".Length));
                    else if (isosr.StartsWith("^"))
                        antecessor = int.Parse(isosr.Substring("^".Length));
                    else if (!string.IsNullOrEmpty(isosr))
                        isos.Add(int.Parse(isosr));
                }
                string skills = (string)data["SKILL"];
                List<string> skill, relatedSkill;
                if (string.IsNullOrEmpty(skills))
                {
                    skill = new List<string>();
                    relatedSkill = new List<string>();
                }
                else if (skills.IndexOf('|') < 0)
                {
                    skill = skills.Split(',').ToList();
                    relatedSkill = new List<string>();
                }
                else
                {
                    int idx = skills.IndexOf('|');
                    skill = skills.Substring(0, idx).Split(',').ToList();
                    relatedSkill = skills.Substring(idx + 1).Split(',').ToList();
                }
                string[] aliass = (data["ALIAS"] as string ?? "").Split(',');
                string[] alias = new string[7];
                for (int i = 0; i < aliass.Length; i += 2)
                {
                    switch (aliass[i])
                    {
                        case "K": alias[0] = aliass[i + 1]; break;
                        case "C": alias[1] = aliass[i + 1]; break;
                        case "T": alias[2] = aliass[i + 1]; break;
                        case "E": alias[3] = aliass[i + 1]; break;
                        case "A": alias[4] = aliass[i + 1]; break;
                        case "F": alias[5] = aliass[i + 1]; break;
                        case "V": alias[6] = aliass[i + 1]; break;
                    }
                }
                string bio = data["BIO"] as string ?? "";
                Hero hero = new Hero(name, code, group, genre, gender, hp, str, dex,
                    spouse, isos, archetype, antecessor, skill, bio)
                {
                    Ofcode = data["OFCODE"] as string,
                    TokenAlias = alias[0],
                    PeopleAlias = alias[1],
                    PlayerTarAlias = alias[2],
                    ExCardsAlias = alias[3],
                    AwakeAlias = alias[4],
                    FolderAlias = alias[5],
                    GuestAlias = alias[6],
                    RelatedSkills = relatedSkill
                };
                hero.SetAvailableParam(gs);
                dicts.Add(code, hero);
            }
            foreach (Hero hero in dicts.Values)
            {
                if (hero.Antecessor != 0 && dicts.ContainsKey(hero.Antecessor))
                    dicts[hero.Antecessor].Pioneer = hero.Avatar;
            }
        }
示例#2
0
文件: Hero.cs 项目: palome06/psd48
 public void ForceChange(Hero hero, int newAvatar, string newCode)
 {
     if (hero != null)
     {
         dicts.Remove(hero.Avatar);
         dicts[newAvatar] = hero;
         hero.ForceChange("Avatar", newAvatar);
         hero.ForceChange("OfCode", newCode);
     }
 }
示例#3
0
 public static List<string> IncrGuestPlayer(Player player, Hero guest, XI xi, int limit)
 {
     List<string> skills = new List<string>();
     List<string> source = guest.Skills.ToList();
     foreach (string skstr in source)
     {
         Skill skill = xi.LibTuple.SL.EncodeSkill(skstr);
         if (skill.IsChange && (limit & 0x1) != 0)
             continue;
         if (skill.IsRestrict && (limit & 0x2) != 0)
             continue;
         skills.Add(skill.Code);
     }
     if (skills.Count > 0)
         xi.RaiseGMessage("G0IS," + player.Uid + ",1," + string.Join(",", skills));
     return skills;
 }
示例#4
0
        public static void DecrGuestPlayer(Player player, Hero guest, XI xi, int limit)
        {
            List<ushort> excds = new List<ushort>();
            excds.AddRange(player.ExCards);
            if (excds.Count > 0)
                xi.RaiseGMessage("G0QZ," + player.Uid + "," + string.Join(",", excds));
            ErasePlayerToken(player, xi.Board, xi.RaiseGMessage, guest.Avatar);

            List<string> skills = new List<string>();
            List<string> source = guest.Skills.ToList(); source.AddRange(guest.RelatedSkills);
            foreach (string skstr in source)
            {
                Skill skill = xi.LibTuple.SL.EncodeSkill(skstr);
                if (skill.IsChange && (limit & 0x1) != 0)
                    continue;
                if (skill.IsRestrict && (limit & 0x2) != 0)
                    continue;
                skills.Add(skill.Code);
            }
            if (skills.Count > 0)
                xi.RaiseGMessage("G0OS," + player.Uid + ",1," + string.Join(",", skills));
        }
示例#5
0
 // Whether a hero's self/iso/banned exist in the field
 private static bool IsHeroPhantomExist(Hero hero, XI xi)
 {
     HeroLib hl = xi.LibTuple.HL;
     Board board = xi.Board;
     Hero hrc = hl.InstanceHero(hero.Archetype);
     foreach (Player py in board.Garden.Values)
     {
         if (py.SelectHero == 0)
             continue;
         if (py.SelectHero == hero.Avatar && py.IsAlive)
             return true;
         foreach (int isoId in hero.Isomorphic)
         {
             if (isoId == py.SelectHero && py.IsAlive) // hero=10202,isoId=10203,py.Sel=10203
                 return true;
         }
         Hero hpy = hl.InstanceHero(py.SelectHero);
         if (hrc != null && hpy.Avatar == hrc.Avatar)
             return true;
         else if (hpy.Archetype == hero.Avatar)
             return true;
     }
     foreach (int ib in board.BannedHero)
     {
         if (ib == hero.Avatar)
             return true;
         foreach (int isoId in hero.Isomorphic)
         {
             if (isoId == ib)
                 return true;
         }
         Hero hpy = hl.InstanceHero(ib);
         if (hrc != null && hpy.Avatar == hrc.Avatar)
             return true;
         else if (hpy.Archetype == hero.Avatar)
             return true;
     }
     return false;
 }
示例#6
0
 // whether the hero can join the team via NPC action
 public static bool IsHeroJoinable(Hero hero, XI xi)
 {
     return hero != null && xi.PCS.ListAllJoinableHeroes().Contains(hero) &&
         !IsHeroPhantomExist(hero, xi);
 }
示例#7
0
 public static List<Hero> GetCallableHeroChain(Hero hero, XI xi)
 {
     List<Hero> heros = new List<Hero>();
     if (hero == null)
         return heros;
     if (hero.Pioneer != 0) // maybe sustitiude it with its pioneer
     {
         Console.WriteLine("Here comes a pioneer " + hero.Pioneer + "(" + hero.Avatar + ")");
         Hero pioneer = xi.LibTuple.HL.InstanceHero(hero.Pioneer);
         if (pioneer != null && xi.PCS.ListAllSeleableHeros().Contains(pioneer))
             hero = pioneer;
     }
     if (IsHeroCallable(hero, xi))
         heros.Add(hero);
     foreach (int isoId in hero.Isomorphic)
     {
         Hero iso = xi.LibTuple.HL.InstanceHero(isoId);
         if (iso != null && IsHeroCallable(iso, xi))
             heros.Add(iso);
     }
     return heros;
 }