public CardAbstractInventory(int capability, int beginSlot) { this.m_capalility = capability; this.m_beginSlot = beginSlot; this.m_cards = new UsersCardInfo[capability]; this.temp_card = new UsersCardInfo(); }
public virtual bool AddCardTo(UsersCardInfo card, int place) { if (card == null || place >= this.m_capalility || place < 0) { return(false); } object @lock; Monitor.Enter(@lock = this.m_lock); try { if (this.m_cards[place] != null) { place = -1; } else { this.m_cards[place] = card; card.Place = place; } } finally { Monitor.Exit(@lock); } if (place != -1) { this.OnPlaceChanged(place); } return(place != -1); }
protected virtual bool ExchangeCards(int fromSlot, int toSlot) { UsersCardInfo usersCardInfo = this.m_cards[fromSlot]; if (fromSlot != toSlot) { this.m_cards[toSlot].TemplateID = usersCardInfo.TemplateID; this.m_cards[toSlot].Attack = usersCardInfo.Attack; this.m_cards[toSlot].Defence = usersCardInfo.Defence; this.m_cards[toSlot].Agility = usersCardInfo.Agility; this.m_cards[toSlot].Luck = usersCardInfo.Luck; this.m_cards[toSlot].Damage = usersCardInfo.Damage; this.m_cards[toSlot].Guard = usersCardInfo.Guard; } else { this.m_cards[toSlot].TemplateID = 0; this.m_cards[toSlot].Attack = 0; this.m_cards[toSlot].Defence = 0; this.m_cards[toSlot].Agility = 0; this.m_cards[toSlot].Luck = 0; this.m_cards[toSlot].Damage = 0; this.m_cards[toSlot].Guard = 0; } return(true); }
public virtual bool RemoveCard(UsersCardInfo item) { if (item == null) { return(false); } int num = -1; object @lock; Monitor.Enter(@lock = this.m_lock); try { for (int i = 0; i < this.m_capalility; i++) { if (this.m_cards[i] == item) { num = i; this.m_cards[i] = null; break; } } } finally { Monitor.Exit(@lock); } if (num != -1) { this.OnPlaceChanged(num); item.Place = -1; } return(num != -1); }
public bool AddCard(UsersCardInfo card, int minSlot) { if (card == null) { return(false); } int place = this.FindFirstEmptySlot(minSlot); return(this.AddCardTo(card, place)); }
public override bool AddCardTo(UsersCardInfo item, int place) { if (base.AddCardTo(item, place)) { item.UserID = this.m_player.PlayerCharacter.ID; item.IsExit = true; return(true); } return(false); }
public virtual void SaveToDatabase() { if (this.m_saveToDb) { using (PlayerBussiness playerBussiness = new PlayerBussiness()) { object @lock; Monitor.Enter(@lock = this.m_lock); try { for (int i = 0; i < this.m_cards.Length; i++) { UsersCardInfo usersCardInfo = this.m_cards[i]; if (usersCardInfo != null && usersCardInfo.IsDirty) { if (usersCardInfo.CardID > 0) { playerBussiness.UpdateCards(usersCardInfo); } else { playerBussiness.AddCards(usersCardInfo); } } } } finally { Monitor.Exit(@lock); } List <UsersCardInfo> removedList; Monitor.Enter(removedList = this.m_removedList); try { foreach (UsersCardInfo current in this.m_removedList) { if (current.CardID > 0) { playerBussiness.UpdateCards(current); } } this.m_removedList.Clear(); } finally { Monitor.Exit(removedList); } } } }
public static int GetProp(UsersCardInfo slot, int type) { int num = 0; for (int i = 0; i < slot.Level; i++) { num += CardMgr.GetGrooveSlot(slot.Type, i, type); } if (slot.CardID != 0) { num += CardMgr.GetPropCard(slot.CardType, slot.CardID, type); } return(num); }
public virtual void UpdateTempCard(UsersCardInfo card) { object @lock; Monitor.Enter(@lock = this.m_lock); try { this.temp_card = card; } finally { Monitor.Exit(@lock); } }
public virtual bool ReplaceCardTo(UsersCardInfo card, int place) { if (card == null || place >= this.m_capalility || place < 0) { return(false); } object @lock; Monitor.Enter(@lock = this.m_lock); try { this.m_cards[place] = card; card.Place = place; this.OnPlaceChanged(place); } finally { Monitor.Exit(@lock); } return(true); }
public virtual void LoadFromDatabase() { if (this.m_saveToDb) { using (PlayerBussiness playerBussiness = new PlayerBussiness()) { UsersCardInfo[] userCardSingles = playerBussiness.GetUserCardSingles(this.m_player.PlayerCharacter.ID); base.BeginChanges(); try { UsersCardInfo[] array = userCardSingles; for (int i = 0; i < array.Length; i++) { UsersCardInfo usersCardInfo = array[i]; this.AddCardTo(usersCardInfo, usersCardInfo.Place); } } finally { base.CommitChanges(); } } } }
public int HandlePacket(GameClient client, GSPacketIn packet) { int num = packet.ReadInt(); PlayerInfo arg_12_0 = client.Player.PlayerCharacter; CardInventory cardBag = client.Player.CardBag; string text = ""; switch (num) { case 0: { int num2 = packet.ReadInt(); int num3 = packet.ReadInt(); int templateID = cardBag.GetItemAt(num2).TemplateID; if (cardBag.FindEquipCard(templateID) && num2 != num3) { text = "Thẻ này đã trang bị!"; } else { if (num2 != num3) { text = "Trang bị thành công!"; } cardBag.MoveItem(num2, num3); client.Player.MainBag.UpdatePlayerProperties(); } if (text != "") { client.Out.SendMessage(eMessageType.Normal, text); } break; } case 1: { int slot = packet.ReadInt(); int count = packet.ReadInt(); ItemInfo itemAt = client.Player.MainBag.GetItemAt(slot); int property = itemAt.Template.Property5; int place = client.Player.CardBag.FindFirstEmptySlot(5); UsersCardInfo usersCardInfo = new UsersCardInfo(); CardTemplateInfo card = CardMgr.GetCard(itemAt.Template.Property5); bool flag = false; if (card != null) { if (client.Player.CardBag.FindPlaceByTamplateId(5, property) == -1) { usersCardInfo.CardType = card.CardType; usersCardInfo.UserID = client.Player.PlayerCharacter.ID; usersCardInfo.Place = place; usersCardInfo.TemplateID = card.CardID; usersCardInfo.isFirstGet = true; usersCardInfo.Attack = 0; usersCardInfo.Agility = 0; usersCardInfo.Defence = 0; usersCardInfo.Luck = 0; usersCardInfo.Damage = 0; usersCardInfo.Guard = 0; client.Player.CardBag.AddCardTo(usersCardInfo, place); client.Out.SendGetCard(client.Player.PlayerCharacter, usersCardInfo); } else { flag = true; } } else { flag = true; } if (flag) { int num4 = CardDataHander.random.Next(5, 50); client.Player.AddCardSoul(num4); client.Player.Out.SendPlayerCardSoul(client.Player.PlayerCharacter, true, num4); } client.Player.MainBag.RemoveCountFromStack(itemAt, count); break; } case 4: { int slot2 = packet.ReadInt(); int count = packet.ReadInt(); ItemInfo itemAt = client.Player.PropBag.GetItemAt(slot2); int id = CardDataHander.random.Next(CardMgr.CardCount()); CardTemplateInfo singleCard = CardMgr.GetSingleCard(id); bool flag2 = false; if (singleCard == null) { flag2 = true; } else { int place2 = client.Player.CardBag.FindFirstEmptySlot(5); int cardID = singleCard.CardID; CardTemplateInfo card2 = CardMgr.GetCard(cardID); UsersCardInfo usersCardInfo2 = new UsersCardInfo(); if (card2 == null) { flag2 = true; } else { if (client.Player.CardBag.FindPlaceByTamplateId(5, cardID) == -1) { usersCardInfo2.CardType = card2.CardType; usersCardInfo2.UserID = client.Player.PlayerCharacter.ID; usersCardInfo2.Place = place2; usersCardInfo2.TemplateID = card2.CardID; usersCardInfo2.isFirstGet = true; usersCardInfo2.Attack = 0; usersCardInfo2.Agility = 0; usersCardInfo2.Defence = 0; usersCardInfo2.Luck = 0; usersCardInfo2.Damage = 0; usersCardInfo2.Guard = 0; client.Player.CardBag.AddCardTo(usersCardInfo2, place2); client.Out.SendGetCard(client.Player.PlayerCharacter, usersCardInfo2); } else { flag2 = true; } } } if (flag2) { int num5 = CardDataHander.random.Next(5, 50); client.Player.AddCardSoul(num5); client.Player.Out.SendPlayerCardSoul(client.Player.PlayerCharacter, true, num5); } client.Player.PropBag.RemoveCountFromStack(itemAt, count); break; } } cardBag.SaveToDatabase(); return(0); }
public bool AddCard(UsersCardInfo card) { return(this.AddCard(card, this.m_beginSlot)); }
public bool UpdateCards(UsersCardInfo info) { bool flag = false; try { SqlParameter[] SqlParameters = new SqlParameter[17] { new SqlParameter("@CardType", (object) info.CardType), new SqlParameter("@UserID", (object) info.UserID), new SqlParameter("@Place", (object) info.Place), new SqlParameter("@TemplateID", (object) info.TemplateID), new SqlParameter("@isFirstGet", (object) (int) (info.isFirstGet ? 1 : 0)), new SqlParameter("@Attack", (object) info.Attack), new SqlParameter("@Defence", (object) info.Defence), new SqlParameter("@Luck", (object) info.Luck), new SqlParameter("@Agility", (object) info.Agility), new SqlParameter("@Damage", (object) info.Damage), new SqlParameter("@Guard", (object) info.Guard), new SqlParameter("@IsExit", (object) (int) (info.IsExit ? 1 : 0)), new SqlParameter("@Level", (object) info.Level), new SqlParameter("@CardGP", (object) info.CardGP), new SqlParameter("@Type", (object) info.Type), new SqlParameter("@CardID", (object) info.CardID), new SqlParameter("@Result", SqlDbType.Int) }; SqlParameters[16].Direction = ParameterDirection.ReturnValue; this.db.RunProcedure("SP_UserCardProp_Update", SqlParameters); flag = (int)SqlParameters[16].Value == 0; } catch (Exception ex) { if (BaseBussiness.log.IsErrorEnabled) BaseBussiness.log.Error((object)"Init", ex); } return flag; }
public bool AddCards(UsersCardInfo item) { bool flag = false; try { SqlParameter[] SqlParameters = new SqlParameter[16]; SqlParameters[0] = new SqlParameter("@CardID", (object)item.CardID); SqlParameters[0].Direction = ParameterDirection.Output; SqlParameters[1] = new SqlParameter("@CardType", (object)item.CardType); SqlParameters[2] = new SqlParameter("@UserID", (object)item.UserID); SqlParameters[3] = new SqlParameter("@Place", (object)item.Place); SqlParameters[4] = new SqlParameter("@TemplateID", (object)item.TemplateID); SqlParameters[5] = new SqlParameter("@isFirstGet", (object)false); SqlParameters[6] = new SqlParameter("@Attack", (object)item.Attack); SqlParameters[7] = new SqlParameter("@Defence", (object)item.Defence); SqlParameters[8] = new SqlParameter("@Luck", (object)item.Luck); SqlParameters[9] = new SqlParameter("@Agility", (object)item.Agility); SqlParameters[10] = new SqlParameter("@Damage", (object)item.Damage); SqlParameters[11] = new SqlParameter("@Guard", (object)item.Guard); SqlParameters[12] = new SqlParameter("@IsExit", (object)(int)(item.IsExit ? 1 : 0)); SqlParameters[13] = new SqlParameter("@Level", (object)item.Level); SqlParameters[14] = new SqlParameter("@CardGP", (object)item.CardGP); SqlParameters[15] = new SqlParameter("@Type", (object)item.Type); flag = this.db.RunProcedure("SP_Users_Cards_Add", SqlParameters); item.CardID = (int)SqlParameters[0].Value; item.IsDirty = false; } catch (Exception ex) { if (BaseBussiness.log.IsErrorEnabled) BaseBussiness.log.Error((object)"Init", ex); } return flag; }
public GSPacketIn SendGetCard(PlayerInfo info, UsersCardInfo card) { throw new NotImplementedException(); }
public GSPacketIn SendPlayerCardSlot(PlayerInfo player, UsersCardInfo card) { throw new NotImplementedException(); }
public int HandlePacket(GameClient client, GSPacketIn packet) { int num = packet.ReadInt(); int num2 = packet.ReadInt(); UsersCardInfo itemByPlace = client.Player.CardBag.GetItemByPlace(0, num2); List <int> list = new List <int>(); string message = "Tẩy điểm thành công!"; int minValue = 1; int maxValue = 10; if (itemByPlace.CardType == 2) { minValue = 10; maxValue = 20; } if (itemByPlace.CardType == 1) { minValue = 15; maxValue = 40; } switch (num) { case 0: for (int i = 0; i < 4; i++) { int num3 = CardResetHandler.random.Next(minValue, maxValue); list.Add(num3); switch (i) { case 0: itemByPlace.Attack = num3; break; case 1: itemByPlace.Defence = num3; break; case 2: itemByPlace.Agility = num3; break; case 3: itemByPlace.Luck = num3; break; } } client.Player.CardBag.UpdateTempCard(itemByPlace); client.Player.RemoveCardSoul(50); client.Player.Out.SendPlayerCardReset(client.Player.PlayerCharacter, list); break; case 1: message = "Cập nhật thay đổi thành công!"; client.Player.CardBag.UpdateCard(); if (num2 < 5) { client.Player.MainBag.UpdatePlayerProperties(); } client.Player.CardBag.SaveToDatabase(); break; } client.Out.SendMessage(eMessageType.Normal, message); return(0); }