public Character(string name, double health, double armor, double abilityPoints, Bag.Bag bag, Faction faction) { this.Name = name; this.BaseHealth = health; this.BaseArmor = armor; this.Armor = armor; this.Health = health; this.AbilityPoints = abilityPoints; this.Bag = bag; }
// 装备只有装上取下两个操作,没有公开的需求,先不提供包装类了。 public override int ProcessEquipementRequest(Equipement rpc) { Login.Session session = Login.Session.Get(rpc); Bag.Bag bag = App.Instance.Game_Bag.GetBag(session.RoleId.Value); if (bag.Items.TryGetValue(rpc.Argument.BagPos, out var bItem)) { int equipPos = GetEquipPosition(bItem.Id); if (equipPos < 0) { return(ReturnCode(ResultCodeCannotEquip)); } BEquips equips = _tequip.GetOrAdd(session.RoleId.Value); Game.Bag.BItem bEquipAdd; if (equips.Items.TryGetValue(equipPos, out var eItem)) { // 装备目标位置已经存在装备,交换。 // 先都删除,这样就能在原位置上交换的装备,否则对于包裹可能加到其他位置。 equips.Items.Remove(equipPos); bag.Remove(rpc.Argument.BagPos, bItem.Id, 1); bag.Add(rpc.Argument.BagPos, new Bag.BItem() { Id = eItem.Id, Number = 1, Extra_Game_Equip_BEquipExtra = eItem.Extra_Game_Equip_BEquipExtra.Copy() } ); bEquipAdd = new Game.Bag.BItem() { Id = bItem.Id, Number = 1, Extra_Game_Equip_BEquipExtra = bItem.Extra_Game_Equip_BEquipExtra.Copy() }; equips.Items.Add(equipPos, bEquipAdd); } else { // 装备目标位置为空 bag.Remove(rpc.Argument.BagPos, bItem.Id, 1); bEquipAdd = new Game.Bag.BItem() { Id = bItem.Id, Number = 1, Extra_Game_Equip_BEquipExtra = bItem.Extra_Game_Equip_BEquipExtra.Copy() }; equips.Items.Add(equipPos, bEquipAdd); } session.SendResponse(rpc); return(Procedure.Success); } return(ReturnCode(ResultCodeItemNotFound)); }
// 装备只有装上取下两个操作,没有公开的需求,先不提供包装类了。 public override int ProcessCEquipement(CEquipement protocol) { Login.Session session = Login.Session.Get(protocol); Bag.Bag bag = App.Instance.Game_Bag.GetBag(session.LoginRoleId.Value); if (bag.Items.TryGetValue(protocol.Argument.BagPos, out var bItem)) { int equipPos = GetEquipPosition(bItem.Id); if (equipPos < 0) { return(Zeze.Transaction.Procedure.LogicError); } BEquips equips = _tequip.GetOrAdd(session.LoginRoleId.Value); Game.Bag.BItem bEquipAdd; if (equips.Items.TryGetValue(equipPos, out var eItem)) { // 装备目标位置已经存在装备,交换。 // 先都删除,这样就能在原位置上交换的装备,否则对于包裹可能加到其他位置。 equips.Items.Remove(equipPos); bag.Remove(protocol.Argument.BagPos, bItem.Id, 1); bag.Add(protocol.Argument.BagPos, new Bag.BItem() { Id = eItem.Id, Number = 1, Extra_Game_Equip_BEquipExtra = eItem.Extra_Game_Equip_BEquipExtra.Copy() } ); bEquipAdd = new Game.Bag.BItem() { Id = bItem.Id, Number = 1, Extra_Game_Equip_BEquipExtra = bItem.Extra_Game_Equip_BEquipExtra.Copy() }; equips.Items.Add(equipPos, bEquipAdd); } else { // 装备目标位置为空 bag.Remove(protocol.Argument.BagPos, bItem.Id, 1); bEquipAdd = new Game.Bag.BItem() { Id = bItem.Id, Number = 1, Extra_Game_Equip_BEquipExtra = bItem.Extra_Game_Equip_BEquipExtra.Copy() }; equips.Items.Add(equipPos, bEquipAdd); } return(Zeze.Transaction.Procedure.Success); } return(Zeze.Transaction.Procedure.LogicError); }
public override int ProcessCUnequipement(CUnequipement protocol) { Login.Session session = Login.Session.Get(protocol); BEquips equips = _tequip.GetOrAdd(session.LoginRoleId.Value); if (equips.Items.TryGetValue(protocol.Argument.EquipPos, out var eItem)) { equips.Items.Remove(protocol.Argument.EquipPos); Bag.Bag bag = App.Instance.Game_Bag.GetBag(session.LoginRoleId.Value); Bag.BItem bItemAdd = new Bag.BItem() { Id = eItem.Id, Number = 1, Extra_Game_Equip_BEquipExtra = (BEquipExtra)eItem.Extra.CopyBean() }; if (0 != bag.Add(-1, bItemAdd)) { return(Zeze.Transaction.Procedure.LogicError); // bag is full } return(Zeze.Transaction.Procedure.Success); } return(Zeze.Transaction.Procedure.LogicError); }
public override int ProcessUnequipementRequest(Unequipement rpc) { Login.Session session = Login.Session.Get(rpc); BEquips equips = _tequip.GetOrAdd(session.RoleId.Value); if (equips.Items.TryGetValue(rpc.Argument.EquipPos, out var eItem)) { equips.Items.Remove(rpc.Argument.EquipPos); Bag.Bag bag = App.Instance.Game_Bag.GetBag(session.RoleId.Value); Bag.BItem bItemAdd = new Bag.BItem() { Id = eItem.Id, Number = 1, Extra_Game_Equip_BEquipExtra = (BEquipExtra)eItem.Extra.CopyBean() }; if (0 != bag.Add(-1, bItemAdd)) { return(ReturnCode(ResultCodeBagIsFull)); // bag is full } session.SendResponse(rpc); return(Procedure.Success); } return(ReturnCode(ResultCodeEquipNotFound)); }
protected Character(string name, double health, double armor, double abilityPoints, Bag.Bag bag, Faction faction) { this.Name = name; this.Health = health; this.BaseHealth = health; this.Armor = armor; this.BaseArmor = armor; this.AbilityPoints = abilityPoints; this.Bag = bag; this.Faction = faction; this.RestHealMultiplier = defaultRestHealMultiplier; this.IsAlive = true; }