public static void InsertDigimon(Digimon digimon) { using (SqlConnection connection = new SqlConnection(connectionString)) { SqlCommand command = new SqlCommand(null, connection); //Query command.CommandText = "INSERT INTO Digimon (name,level,type,attribute,size) VALUES (@name,@level,@type,@attribute,@size)"; command.Parameters.AddWithValue("@name", digimon.name); command.Parameters.AddWithValue("@level", digimon.level); command.Parameters.AddWithValue("@type", digimon.type); command.Parameters.AddWithValue("@attribute", digimon.attribute); command.Parameters.AddWithValue("@size", digimon.size); try { connection.Open(); command.ExecuteNonQuery(); } catch (Exception ex) { Console.WriteLine(ex.Message); } connection.Close(); } }
protected override bool GetStarterInfo(ref Digimon digimon, Tamer tamer) { if (LogManager != null) { LogManager.InfoFormat("Obtaining starter digimon for tamer \"{0}\"", tamer.Name); } HtmlDocument doc = new HtmlDocument(); string html = DownloadContent(string.Format(STR_URL_STARTER_RANK, tamer.Name, tamer.Guild.Server.Identifier)); doc.LoadHtml(html); HtmlNode partnerNode; try { partnerNode = doc.DocumentNode.SelectNodes("//table[@class='forum_list']")[1].SelectSingleNode(".//tbody//tr[not(@onmouseover)]"); } catch { return(false); } if (partnerNode != null) { digimon.Rank = CheckRankNode(partnerNode.SelectSingleNode(".//td[1]")); digimon.Name = ClearStr(partnerNode.SelectSingleNode(".//td[2]//label").InnerText); digimon.Level = Convert.ToByte(ClearStr(partnerNode.SelectSingleNode(".//td[3]").InnerText)); } return(partnerNode != null); }
public UpdateStats(Character Tamer, Digimon Partner, byte uByte) { packet.Type(1043); packet.WriteShort((short)Tamer.MaxHP); packet.WriteShort((short)Tamer.MaxDS); packet.WriteShort((short)Tamer.HP); packet.WriteShort((short)Tamer.DS); packet.WriteShort((short)Tamer.AT); packet.WriteShort((short)Tamer.DE); packet.WriteByte(uByte); packet.WriteShort((short)Tamer.MS); packet.WriteShort(Partner.Stats.MaxHP); packet.WriteShort(Partner.Stats.MaxDS); packet.WriteShort(Partner.Stats.HP); packet.WriteShort(Partner.Stats.DS); packet.WriteShort(Partner.Stats.Intimacy); packet.WriteShort(Partner.Stats.AT); packet.WriteShort(Partner.Stats.DE); packet.WriteShort(Partner.Stats.CR); packet.WriteShort(Partner.Stats.AS); packet.WriteShort(Partner.Stats.EV); packet.WriteShort(Partner.Stats.HT); packet.WriteShort(8000); }
//Get Digimon by Name public static List <Digimon> getDigimon(string name) { var dt = new DataTable(); using (SqlConnection connection = new SqlConnection(connectionString)) { SqlCommand command = new SqlCommand(null, connection); command.CommandText = $"select * from Digimon where name = '{name}'"; //abrir la conexion connection.Open(); var DataAdapter = new SqlDataAdapter(command); DataAdapter.Fill(dt); listDigimons = new List <Digimon>(); if (dt != null && dt.Rows.Count > 0) { Digimon digimon = new Digimon(); digimon.name = dt.Rows[0]["name"].ToString(); digimon.size = int.Parse(dt.Rows[0]["size"].ToString()); digimon.attribute = dt.Rows[0]["attribute"].ToString(); //digimon.created_at = dt.Rows[0]["name"].ToString(); digimon.level = dt.Rows[0]["level"].ToString(); digimon.type = dt.Rows[0]["type"].ToString(); digimon.idDigimon = int.Parse(dt.Rows[0]["idDigimon"].ToString()); listDigimons.Add(digimon); } return(listDigimons); } }
private void Digimon(Digimon Mon) { packet.WriteUInt(Mon.Model); packet.WriteString(Mon.Name); packet.WriteByte((byte)Mon.Scale); packet.WriteShort((short)Mon.Size); packet.WriteInt(Mon.EXP); packet.WriteShort((short)Mon.Level); packet.WriteBytes(Mon.Stats.ToArray()); packet.WriteShort(600); //Unknown packet.WriteShort(10); //Unknown packet.WriteInt(Mon.Species); packet.WriteByte((byte)Mon.Forms.Count); for (int i = 0; i < Mon.Forms.Count; i++) { EvolvedForm form = Mon.Forms[i]; form.uByte5 = 0x1d; form.uByte4 = 0x34; form.b128 = 129; form.b0 = 0x95; form.Skill1 = 8; form.Skill2 = 8; packet.WriteBytes(form.ToArray()); } }
public Hatch(Digimon Mon, int slot) { packet.Type(1038); packet.WriteInt(slot); packet.WriteUInt(Mon.Model); packet.WriteString(Mon.Name); packet.WriteShort((short)Mon.Size); packet.WriteInt(Mon.EXP); packet.WriteShort((short)Mon.Level); packet.WriteBytes(Mon.Stats.ToArray()); packet.WriteShort(600); //Unknown packet.WriteShort(10); //Unknown packet.WriteInt(Mon.Species); packet.WriteByte((byte)Mon.Forms.Count); for (int i = 0; i < Mon.Forms.Count; i++) { EvolvedForm form = Mon.Forms[i]; form.uByte5 = 0x1d; form.uByte4 = 0x34; form.b128 = 129; form.b0 = 0x95; form.Skill1 = 8; form.Skill2 = 8; packet.WriteBytes(form.ToArray()); } packet.WriteBytes(new byte[22]); }
protected override bool GetMercenaryInfo(ref Digimon digimon, Tamer tamer) { //we don't need starters info if (digimon.Type.IsStarter) { return(false); } if (LogManager != null) { LogManager.InfoFormat("Obtaining detailed data of digimon \"{0}\" for tamer \"{1}\"", digimon.Name, tamer.Name); } HtmlNode ranking = tryLoadNode(string.Format(STR_URL_MERC_SIZE_RANK, tamer.Name, "srv" + tamer.Guild.Server.Identifier.ToString(), digimon.Type.Code), STR_RANKING_NODE); HtmlNodeCollection dlist = ranking.SelectNodes("//tr/td[@class='tamer2']"); if (dlist != null) { for (int i = 0; i < dlist.Count; i++) { if (ClearStr(ranking.SelectNodes("//td[@class='tamer2']")[i].InnerText) == tamer.Name) { string size = ranking.SelectNodes("//td[@class='size']")[i + 3].InnerText.Replace("cm", ""); string size_cm = size.Substring(0, size.IndexOf(' ')); double SizeCm = 0; double.TryParse(size_cm.Replace('.', ','), out SizeCm); digimon.SizeCm = SizeCm; digimon.SizePc = Convert.ToInt32(size.Substring(size.LastIndexOf('(') + 1, size.LastIndexOf('%') - size.LastIndexOf('(') - 1)); digimon.SizeRank = Convert.ToInt32(ClearStr(ranking.SelectNodes("//td[@class='ranking']")[i + 3].InnerText)); digimon.Name = ClearStr(ranking.SelectNodes("//td[@class='name']")[i + 3].InnerText); return(true); } } } return(false); }
protected override bool GetStarterInfo(ref Digimon digimon, Tamer tamer) { if (digimon.Type == null) { return(false); } if (LogManager != null) { LogManager.InfoFormat("Obtaining starter digimon for tamer \"{0}\"", tamer.Name); } HtmlNode ranking = tryLoadNode(string.Format(STR_URL_STARTER_RANK, tamer.Name, "srv" + tamer.Guild.Server.Identifier), STR_RANKING_NODE); HtmlNodeCollection dlist = ranking.SelectNodes("//tr/td[@class='tamer2']"); if (dlist != null) { for (int i = 0; i < dlist.Count; i++) { if (ClearStr(ranking.SelectNodes("//td[@class='tamer2']")[i].InnerText) == tamer.Name) { digimon.Rank = Convert.ToInt32(ClearStr(ranking.SelectNodes("//td[@class='ranking']")[i + 3].InnerText)); digimon.Name = ClearStr(ranking.SelectNodes("//td[@class='name']")[i + 3].InnerText); digimon.Level = Convert.ToByte(ClearStr(ranking.SelectNodes("//td[@class='level']")[i + 3].InnerText)); return(true); } } } return(false); }
public void CreateDigimon() { var instant = Instant.FromDateTimeOffset(new DateTimeOffset(2020, 3, 24, 11, 45, 0, TimeSpan.Zero)); var digimon = Digimon.Create("Bakugon", 25, instant); digimon.Niveau.Should().Be(25); digimon.Nom.Should().Be("Bakugon"); }
private static bool MergeDigimon(IDatabaseContext context, Digimon mergeDigimon, Digimon storedDigimon) { if (mergeDigimon.Tamer.Guild.IsDetailed) { MergeEntity(mergeDigimon, storedDigimon, false, "Rank", "Level", "Name", "SizeCm", "SizePc", "SizeRank"); } else { MergeEntity(mergeDigimon, storedDigimon, false, "Rank", "Level"); } return true; }
public Player() { this.id = 0; this.name = ""; this.avatarID = 0; this.level = 1; this.experience = 0; this.digimon = null; }
public Player(Digimon dm) { this.id = 0; this.name = ""; this.avatarID = 0; this.level = 1; this.experience = 0; this.digimon = dm; }
public Player(int id, string name, int level, double exp, Digimon dm) { this.id = id; this.name = name; this.avatarID = id; this.level = level; this.experience = exp; this.digimon = dm; }
protected override bool GetGuildInfo(ref Guild guild, bool isDetailed) { if (LogManager != null) { LogManager.InfoFormat("Obtaining info of {0}", guild.Name); } List <Tamer> tamerList = new List <Tamer>(); HtmlNode ranking = tryLoadNode(string.Format(STR_URL_GUILD_PAGE, guild.Identifier, "srv" + guild.Server.Identifier), STR_RANKING_NODE); HtmlNodeCollection tlist = ranking.SelectNodes("//tr/td[@class='level']"); using (IDatabaseContext context = DatabaseManager.CreateContext()) { for (int i = 0; i < tlist.Count; i++) { Tamer tamer = new Tamer() { Guild = guild, Name = ClearStr(ranking.SelectNodes("//td[@class='guild']")[i].InnerText), Level = Convert.ToByte(ClearStr(ranking.SelectNodes("//td[@class='level']")[i].InnerText)), Rank = Convert.ToInt32(ClearStr(ranking.SelectNodes("//td[@class='ranking']")[i].InnerText)) }; OnStatusChanged(DMODownloadStatusCode.GETTING_TAMER, tamer.Name, i, tlist.Count - 1); string tamerType = ranking.SelectNodes("//td[@class='guild']//img")[i].GetAttributeValue("src", null); tamerType = tamerType.Substring(tamerType.LastIndexOf('/') + 1, tamerType.LastIndexOf('.') - tamerType.LastIndexOf('/') - 1); tamer.Type = context.FindTamerTypeByCode(Convert.ToInt32(tamerType)); Regex r = new Regex(STR_TAMER_ID_REGEX, RegexOptions.IgnoreCase | RegexOptions.Singleline); Match m = r.Match(ranking.SelectNodes("//td[@class='detail']")[i].InnerHtml); if (m.Success) { tamer.AccountId = Convert.ToInt32(m.Groups[2].ToString()); tamer.Digimons = GetDigimons(tamer, isDetailed); Digimon partner = tamer.Digimons.FirstOrDefault(d => d.Type.IsStarter); if (partner != null) { partner.Name = ClearStr(ranking.SelectNodes("//td[@class='partner']")[i].InnerText); } tamerList.Add(tamer); if (LogManager != null) { LogManager.InfoFormat("Found tamer \"{0}\"", tamer.Name); } } } } if (tamerList.Count == 0) { return(false); } guild.Tamers = tamerList; return(true); }
/// <summary> /// Switch Mon1 to Mon2 /// </summary> /// <param name="Mon1"></param> /// <param name="Mon2"></param> public DigimonSwitch(short DigimonHandle, byte slot, Digimon Mon1, Digimon Mon2) { packet.Type(1041); packet.WriteShort(DigimonHandle); packet.WriteInt(Mon1.Species); packet.WriteByte(slot); packet.WriteInt(Mon2.Species); packet.WriteByte((byte)Mon2.Level); packet.WriteString(Mon2.Name); packet.WriteShort(Mon2.Size); }
private void OpenPages() { currentScreen = ScreenDatabase.Pages; pageIndex = 0; string displayDigimon = galleryList[galleryIndex]; pageDigimon = Database.GetDigimon(displayDigimon); DrawScreen(); }
public DigimonArchive(int SlotsUnlocked, int TotalSlots, Dictionary <int, Digimon> lDigis) { packet.Type(3204); packet.WriteInt(SlotsUnlocked); foreach (KeyValuePair <int, Digimon> kvp in lDigis) { Digimon Mon = kvp.Value; packet.WriteInt(kvp.Key); Digimon(Mon); } packet.WriteInt(TotalSlots); }
public ActionResult Find(String name) { Digimon digimon = GetByName(name); if (digimon != null) { return(View("Index", digimon)); } else { return(HttpNotFound()); } }
public SpawnPlayer(Character Tamer, Digimon Partner) { packet.Type(1006); packet.WriteShort(513); packet.WriteByte(0); packet.WriteInt(Partner.Location.PosX); packet.WriteInt(Partner.Location.PosY); //Start Tamer Structure packet.WriteUInt(Partner.Model); packet.WriteInt(Partner.Location.PosX); packet.WriteInt(Partner.Location.PosY); packet.WriteString(Partner.Name); packet.WriteShort(Partner.Size); packet.WriteByte((byte)Partner.Level); packet.WriteUInt(Partner.Model); //Related to riding mode packet.WriteShort(Partner.Stats.MS); packet.WriteShort(Tamer.TamerHandle); packet.WriteByte(0xff); packet.WriteInt(0); packet.WriteInt(Tamer.Location.PosX); packet.WriteInt(Tamer.Location.PosY); packet.WriteUInt(Tamer.intHandle); packet.WriteInt(Tamer.Location.PosX); packet.WriteInt(Tamer.Location.PosY); packet.WriteString(Tamer.Name); packet.WriteByte((byte)Tamer.Level); packet.WriteUInt(Tamer.intHandle); packet.WriteShort((short)Tamer.MS); packet.WriteByte(0xff); for (int i = 0; i < 9; i++) { packet.WriteBytes(Tamer.Equipment[i].ToArray()); } packet.WriteInt(0); packet.WriteInt(0); packet.WriteShort(Tamer.DigimonHandle); packet.WriteByte(0); packet.WriteShort(0); packet.WriteShort(0); packet.WriteShort(0); packet.WriteByte(0); //packet.WriteShort(Tamer.DigimonHandle); //packet.WriteInt(Partner.Location.PosX); //packet.WriteInt(Partner.Location.PosY); //packet.WriteByte(0); }
public static void MakeHandles(Character Tamer, uint time_t) { Tamer.intHandle = (uint)(Tamer.ProperModel + Rand.Next(1, 255)); for (int i = 0; i < Tamer.DigimonList.Count; i++) { if (Tamer.DigimonList[i] == null) { continue; } Digimon mon = Tamer.DigimonList[i]; mon.Model = GetModel(mon.ProperModel()); } Tamer.DigimonHandle = Tamer.Partner.Handle; }
public async Task Update(Digimon digimon) { var sql = @"UPDATE digimons SET nom = @Nom, niveau = @Niveau, updated_at = @UpdatedAt WHERE id = @Id;"; await connection.ExecuteAsync( sql, new { nom = digimon.Nom, niveau = digimon.Niveau, UpdatedAt = digimon.UpdatedAt, Id = digimon.Id }); }
public async Task <Digimon> Create(Digimon digimon, CancellationToken cancellationToken = default) { var id = await connection.QuerySingleOrDefaultAsync <Guid>( @"INSERT INTO digimons(nom, niveau, created_at, updated_at) VALUES (@Nom, @Niveau, @CreatedAt, @UpdatedAt) RETURNING id;", digimon); return(new Digimon( id, digimon.Nom, digimon.Niveau, digimon.CreatedAt, digimon.UpdatedAt)); }
public void SaveToSystem(Digimon digimon) { Debug.Log("On Create"); var path = Application.dataPath + "/Digimon API/DigimonJson/" + digimon.name + ".json"; Debug.Log(path); if (!File.Exists(path)) { Debug.Log("Created"); File.WriteAllText(path, JsonUtility.ToJson(digimon, true)); } else { Debug.Log("FailExist"); } }
public MovePlayer(Character Tamer) { Digimon Partner = Tamer.Partner; packet.Type(0x3ee); packet.WriteShort(0x205); packet.WriteByte(0); packet.WriteShort(Tamer.TamerHandle); packet.WriteInt(Tamer.Location.PosX); packet.WriteInt(Tamer.Location.PosY); packet.WriteShort(Tamer.DigimonHandle); packet.WriteInt(Partner.Location.PosX); packet.WriteInt(Partner.Location.PosY); packet.WriteByte(0); }
// GET: Digimon public ActionResult Index(int?id) { if (!id.HasValue) { id = 0; } Digimon digimon = GetById(id.Value); if (digimon != null) { return(View(digimon)); } else { return(HttpNotFound()); } }
private void CheckCode() { Digimon digimon = Database.GetDigimonFromCode(CurrentInputString); if (digimon == null) { if (submitError) { ReturnedDigimon = Constants.DEFAULT_DIGIMON; CloseApp(); } inputStatus = 2; } else { ReturnedDigimon = digimon.name; CloseApp(); } }
public void SetCurrentObjectInformation(IFloorLayoutObject mapObject) { ResetCurrentObjectInformation(); ObjectTypeLabel.Text = $"Type: {mapObject.ObjectType}"; ObjectPositionLabel.Text = GridPosHexCheckBox.Checked ? $"Position: ({mapObject.Position.x:X2}, {mapObject.Position.y:X2})" : $"Position: {mapObject.Position}"; switch (mapObject.ObjectType) { case IFloorLayoutObject.MapObjectType.Warp: Warp warp = (Warp)mapObject; ObjectSubTypeLabel.Text = $"Sub type: {warp.Type}"; break; case IFloorLayoutObject.MapObjectType.Chest: Chest chest = (Chest)mapObject; ObjectSlotOneLabel.Text = $"Slot 1: {chest.chestSlots[0].ItemName} - {chest.chestSlots[0].TrapLevel}"; ObjectSlotTwoLabel.Text = $"Slot 2: {chest.chestSlots[1].ItemName} - {chest.chestSlots[1].TrapLevel}"; ObjectSlotThreeLabel.Text = $"Slot 3: {chest.chestSlots[2].ItemName} - {chest.chestSlots[2].TrapLevel}"; ObjectSlotFourLabel.Text = $"Slot 4: {chest.chestSlots[3].ItemName} - {chest.chestSlots[3].TrapLevel}"; break; case IFloorLayoutObject.MapObjectType.Trap: Trap trap = (Trap)mapObject; ObjectSubTypeLabel.Text = $"Sub type: {trap.Type}"; ObjectSlotOneLabel.Text = $"Slot 1: {trap.TrapSlots[0]}"; ObjectSlotTwoLabel.Text = $"Slot 2: {trap.TrapSlots[1]}"; ObjectSlotThreeLabel.Text = $"Slot 3: {trap.TrapSlots[2]}"; ObjectSlotFourLabel.Text = $"Slot 4: {trap.TrapSlots[3]}"; break; case IFloorLayoutObject.MapObjectType.Digimon: Digimon digimon = (Digimon)mapObject; ObjectSubTypeLabel.Text = $"Pack 1 Level: {digimon.DigimonPacks[0].Level}"; ObjectSlotOneLabel.Text = $"Slot 1: {digimon.DigimonPacks[0].ObjectModelDigimonName:X2}"; ObjectSlotTwoLabel.Text = $"Slot 2: {digimon.DigimonPacks[1].ObjectModelDigimonName:X2}"; ObjectSlotThreeLabel.Text = $"Slot 3: {digimon.DigimonPacks[2].ObjectModelDigimonName:X2}"; ObjectSlotFourLabel.Text = $"Slot 4: {digimon.DigimonPacks[3].ObjectModelDigimonName:X2}"; break; default: break; } }
public static Digimon GetDigimon(uint DigiId) { Digimon digimon = null; try { using (MySqlConnection mysql = Connect()) using (MySqlCommand cmd = new MySqlCommand( "SELECT * FROM `digimon` WHERE `digimonId` = @id" , mysql)) { cmd.Parameters.AddWithValue("@id", DigiId); using (MySqlDataReader read = cmd.ExecuteReader()) { if (read.HasRows) { if (read.Read()) { digimon = new Digimon(); digimon.DigiId = DigiId; digimon.CharacterId = (int)read["characterId"]; digimon.Name = (string)read["digiName"]; digimon.Level = (int)read["digiLv"]; digimon.Species = (int)read["digiType"]; digimon.CurrentForm = digimon.Species; digimon.Size = (short)(int)read["digiSize"]; digimon.Scale = (int)read["digiScale"]; ResetModel(DigiId, digimon.Species); } } } } } catch (Exception e) { Console.WriteLine("Error: GetDigimon({1})\n{0}", e, DigiId); } return(digimon); }
protected override bool GetMercenaryInfo(ref Digimon digimon, Tamer tamer) { //we don't need starters info if (digimon.Type.IsStarter) { return(false); } if (LogManager != null) { LogManager.InfoFormat("Obtaining detailed data of digimon \"{0}\" for tamer \"{1}\"", digimon.Name, tamer.Name); } string html = DownloadContent(string.Format(STR_URL_MERC_SIZE_RANK, tamer.Name, tamer.Guild.Server.Identifier, digimon.Type.Code)); HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(html); HtmlNode partnerNode; try { partnerNode = doc.DocumentNode.SelectNodes("//table[@class='forum_list']")[1].SelectSingleNode(".//tbody//tr[not(@onmouseover)]"); } catch { return(false); } if (partnerNode != null) { digimon.SizeRank = Convert.ToInt32(ClearStr(partnerNode.SelectSingleNode(".//td[1]").InnerText)); digimon.Name = ClearStr(partnerNode.SelectSingleNode(".//td[2]//label").InnerText); Regex r = new Regex(STR_DIGIMON_SIZE, RegexOptions.IgnoreCase | RegexOptions.Singleline); Match m = r.Match(partnerNode.SelectSingleNode(".//td[3]").InnerHtml); if (m.Success) { digimon.SizeCm = Convert.ToInt32(m.Groups[1].ToString()); digimon.SizePc = Convert.ToInt32(m.Groups[3].ToString()); return(true); } } return(false); }
public static void SaveDigimon(Digimon digimon) { try { using (MySqlConnection connection = Connect()) { Query qry = new Query(Query.QueryMode.UPDATE, "digimon", new Tuple <string, object>("digimonId", digimon.DigiId)); qry.Add("digiModel", digimon.CurrentForm); qry.Add("digiName", digimon.Name); qry.Add("digiLv", digimon.Level); qry.Add("exp", digimon.EXP); qry.Add("digiSize", digimon.Size); qry.Add("maxHP", digimon.Stats.MaxHP); qry.Add("maxDS", digimon.Stats.MaxDS); qry.Add("HP", digimon.Stats.HP); qry.Add("DS", digimon.Stats.DS); qry.Add("AT", digimon.Stats.AT); qry.Add("DE", digimon.Stats.DE); qry.Add("sync", digimon.Stats.Intimacy); qry.Add("HT", digimon.Stats.HT); qry.Add("EV", digimon.Stats.EV); qry.Add("CR", digimon.Stats.CR); qry.Add("MS", digimon.Stats.MS); qry.Add("forms", digimon.Forms.Serialize()); using (MySqlCommand cmd = qry.GetCommand(connection)) { cmd.ExecuteNonQuery(); } } } catch (Exception e) { Console.WriteLine("Error: GetDigimon({1})\n{0}", e, digimon); } }