public void GetItemsMessage(LKCamelot.LoginProto msg, LKCamelot.model.Player play) { LoginProto curResp = new LoginProto(); curResp.GetItemsResponseP = new GetItemsResponse(); var templ = new List <TraderItem>(); foreach (var item in play.Inventory) { var ti = new TraderItem(); ti.Name = item.Name; if (item.Stage > 0) { ti.Name += "<br>" + item.NPrefix() + "(" + item.Stage + ")"; } ti.Quantity = item.Quantity.ToString(); ti.Serial = ((int)(item.m_Serial)).ToString(); ti.Sprite = item.m_ItemID.ToString(); ti.Stage = item.Stage.ToString(); templ.Add(ti); } curResp.GetItemsResponseP.traderItem = templ; iweb.Send(CreateBuffer(curResp)); }
public void ClaimAuction(LKCamelot.LoginProto msg) { LKCamelot.script.item.AuctionItem ai; try { ai = LKCamelot.model.World.NewAuctions[Convert.ToInt32(msg.ClaimAuctionP.Serial)]; } catch { return; } if (ai != null) { if (ai.item.ParSer == player.Serial) { ai.flags = 0; LKCamelot.script.item.AuctionItem it; LKCamelot.model.World.NewAuctions.TryRemove(ai.item.m_Serial, out it); var titem = ai.item; titem.m_InvSlot = player.FreeBankSlot; titem.m_Loc = null; titem.m_Parent = player; titem.ParSer = player.Serial; LKCamelot.model.World.NewItems.TryAdd(titem.m_Serial, titem); LoginProto curResp = new LoginProto(); curResp.ClaimAuctionResponseP = new ClaimAuctionResponse(); curResp.ClaimAuctionResponseP.slot = titem.InvSlot.ToString(); iweb.Send(CreateBuffer(curResp)); CharCurMessage(player); GetAuctions(player); } } }
public void KeepAlive(LKCamelot.model.Player play) { LoginProto curResp = new LoginProto(); curResp.KeepAliveResponseP = new KeepAliveResponse(); curResp.KeepAliveResponseP.result = "1"; player.keepalive = Server.tickcount.ElapsedMilliseconds; iweb.Send(CreateBuffer(curResp)); }
public void CharCurMessage(LKCamelot.model.Player play) { LoginProto curResp = new LoginProto(); curResp.CharCurrencyResponseP = new CharCurrencyReponse(); curResp.CharCurrencyResponseP.Gold = play.Gold.ToString(); // curResp.CharCurrencyResponseP.AGold = play.Gold.ToString(); iweb.Send(CreateBuffer(curResp)); }
public void LoginMessage(LKCamelot.LoginProto msg) { var accs = LKCamelot.model.PlayerHandler.getSingleton().add.Values; player = accs.Where(xe => xe.Name == msg.LoginP.user).FirstOrDefault(); bool result; if (player.Pass.Length > 10) { result = LKCamelot.util.Cryption.CheckHashPass(player.Pass, player.Name, msg.LoginP.shapassword); } else { result = (player.Pass == msg.LoginP.shapassword); } LoginProto logResp = new LoginProto(); logResp.LoginReponseP = new LoginResponse(); if (player != null) { if (player.loggedIn) { logResp.LoginReponseP.loginresp = LoginResponse.LoginStatus.LOGGEDIN; } else if (!result) { logResp.LoginReponseP.loginresp = LoginResponse.LoginStatus.WRONGPASS; } else if (result) { player.loggedIn = true; player.apistate = 1; player.keepalive = Server.tickcount.ElapsedMilliseconds; logResp.LoginReponseP.loginresp = LoginResponse.LoginStatus.SUCCESS; logResp.LoginReponseP.classtype = ((int)player.m_Class).ToString(); } } else { logResp.LoginReponseP.loginresp = LoginResponse.LoginStatus.WRONGPASS; } iweb.Send(CreateBuffer(logResp)); }
public void BuyAuction(LKCamelot.LoginProto msg) { LoginProto curResp = new LoginProto(); curResp.BuyAuctionResponseP = new BuyAuctionResponse(); curResp.BuyAuctionResponseP.result = "2"; LKCamelot.script.item.AuctionItem ai; try{ ai = LKCamelot.model.World.NewAuctions[Convert.ToInt32(msg.BuyAuctionP.ItemSerial)]; } catch { iweb.Send(CreateBuffer(curResp)); return; } if (ai != null && ai.flags == 1) { if (player.Gold > ai.goldprice && msg.BuyAuctionP.useagold == false) { player.m_Gold -= Convert.ToUInt64(ai.goldprice); var owner = Server.playerHandler.add.Values.Where(xe => xe.Serial == ai.item.ParSer).FirstOrDefault(); owner.m_Gold += Convert.ToUInt64(ai.goldprice); ai.buyerSerial = player.Serial; ai.state = script.item.aucState.sold; ai.item.ParSer = player.Serial; ai.flags = 2; curResp.BuyAuctionResponseP.result = "1"; } } iweb.Send(CreateBuffer(curResp)); CharCurMessage(player); GetAuctions(player); }
public void LoginMessage(LKCamelot.LoginProto msg) { var accs = LKCamelot.model.PlayerHandler.getSingleton().add.Values; player = accs.Where(xe => xe.Name == msg.LoginP.user).FirstOrDefault(); bool result; if (player.Pass.Length > 10) result = LKCamelot.util.Cryption.CheckHashPass(player.Pass, player.Name, msg.LoginP.shapassword); else result = (player.Pass == msg.LoginP.shapassword); LoginProto logResp = new LoginProto(); logResp.LoginReponseP = new LoginResponse(); if (player != null) { if (player.loggedIn) { logResp.LoginReponseP.loginresp = LoginResponse.LoginStatus.LOGGEDIN; } else if (!result) { logResp.LoginReponseP.loginresp = LoginResponse.LoginStatus.WRONGPASS; } else if (result) { player.loggedIn = true; player.apistate = 1; player.keepalive = Server.tickcount.ElapsedMilliseconds; logResp.LoginReponseP.loginresp = LoginResponse.LoginStatus.SUCCESS; logResp.LoginReponseP.classtype = ((int)player.m_Class).ToString(); } } else { logResp.LoginReponseP.loginresp = LoginResponse.LoginStatus.WRONGPASS; } iweb.Send(CreateBuffer(logResp)); }
public void GetItemsMessage(LKCamelot.LoginProto msg, LKCamelot.model.Player play) { LoginProto curResp = new LoginProto(); curResp.GetItemsResponseP = new GetItemsResponse(); var templ = new List<TraderItem>(); foreach (var item in play.Inventory) { var ti = new TraderItem(); ti.Name = item.Name; if (item.Stage > 0) ti.Name += "<br>" + item.NPrefix() + "(" + item.Stage + ")"; ti.Quantity = item.Quantity.ToString(); ti.Serial = ((int)(item.m_Serial)).ToString(); ti.Sprite = item.m_ItemID.ToString(); ti.Stage = item.Stage.ToString(); templ.Add(ti); } curResp.GetItemsResponseP.traderItem = templ; iweb.Send(CreateBuffer(curResp)); }
public void GetAuctions(LKCamelot.model.Player play) { var aucs = LKCamelot.model.World.NewAuctions.Values.OrderBy(xe => xe.item.Name).ThenBy(xe => xe.item.Stage).ThenBy(xe => xe.goldprice).ToList(); LoginProto curResp = new LoginProto(); curResp.GetAuctionsResponseP = new GetAuctionsResponse(); var templ = new List<AuctionTraderItem>(); foreach (var item in aucs) { if (item.state == script.item.aucState.sold && item.buyerSerial != play.Serial) continue; var tt = new AuctionTraderItem(); var ti = new TraderItem(); ti.Name = item.item.Name; if (item.item.Stage > 0) ti.Name += "<br>" + item.item.NPrefix() + "("+ item.item.Stage +")"; ti.Quantity = item.item.Quantity.ToString(); ti.Serial = ((int)item.item.m_Serial).ToString(); ti.Sprite = item.item.m_ItemID.ToString(); ti.Stage = item.item.Stage.ToString(); tt.Gold = item.goldprice.ToString(); tt.AGold = item.agoldprice.ToString(); tt.flags = item.flags.ToString(); tt.BItem = ti; tt.count = 1; if (item.sellerSerial == play.Serial && item.state == script.item.aucState.forsale) tt.flags = "3"; if (item.buyerSerial == play.Serial && item.state == script.item.aucState.sold) tt.flags = "2"; templ.Add(tt); } var templ2 = templ.ToList(); AuctionTraderItem lastitem = new AuctionTraderItem(); lastitem.BItem = new TraderItem(); foreach (var temp in templ2) { if (temp.BItem.Name == lastitem.BItem.Name && temp.flags == "1") { templ.Remove(temp); templ[templ.IndexOf(lastitem)].count++; continue; } lastitem = temp; } curResp.GetAuctionsResponseP.auctiontraderItem = templ; iweb.Send(CreateBuffer(curResp)); }
public void BuyAuction(LKCamelot.LoginProto msg) { LoginProto curResp = new LoginProto(); curResp.BuyAuctionResponseP = new BuyAuctionResponse(); curResp.BuyAuctionResponseP.result = "2"; LKCamelot.script.item.AuctionItem ai; try{ ai = LKCamelot.model.World.NewAuctions[Convert.ToInt32(msg.BuyAuctionP.ItemSerial)]; } catch{ iweb.Send(CreateBuffer(curResp)); return;} if (ai != null && ai.flags == 1) { if (player.Gold > ai.goldprice && msg.BuyAuctionP.useagold == false) { player.m_Gold -= Convert.ToUInt64(ai.goldprice); var owner = Server.playerHandler.add.Values.Where(xe => xe.Serial == ai.item.ParSer).FirstOrDefault(); owner.m_Gold += Convert.ToUInt64(ai.goldprice); ai.buyerSerial = player.Serial; ai.state = script.item.aucState.sold; ai.item.ParSer = player.Serial; ai.flags = 2; curResp.BuyAuctionResponseP.result = "1"; } } iweb.Send(CreateBuffer(curResp)); CharCurMessage(player); GetAuctions(player); }
public void GetAuctions(LKCamelot.model.Player play) { var aucs = LKCamelot.model.World.NewAuctions.Values.OrderBy(xe => xe.item.Name).ThenBy(xe => xe.item.Stage).ThenBy(xe => xe.goldprice).ToList(); LoginProto curResp = new LoginProto(); curResp.GetAuctionsResponseP = new GetAuctionsResponse(); var templ = new List <AuctionTraderItem>(); foreach (var item in aucs) { if (item.state == script.item.aucState.sold && item.buyerSerial != play.Serial) { continue; } var tt = new AuctionTraderItem(); var ti = new TraderItem(); ti.Name = item.item.Name; if (item.item.Stage > 0) { ti.Name += "<br>" + item.item.NPrefix() + "(" + item.item.Stage + ")"; } ti.Quantity = item.item.Quantity.ToString(); ti.Serial = ((int)item.item.m_Serial).ToString(); ti.Sprite = item.item.m_ItemID.ToString(); ti.Stage = item.item.Stage.ToString(); tt.Gold = item.goldprice.ToString(); tt.AGold = item.agoldprice.ToString(); tt.flags = item.flags.ToString(); tt.BItem = ti; tt.count = 1; if (item.sellerSerial == play.Serial && item.state == script.item.aucState.forsale) { tt.flags = "3"; } if (item.buyerSerial == play.Serial && item.state == script.item.aucState.sold) { tt.flags = "2"; } templ.Add(tt); } var templ2 = templ.ToList(); AuctionTraderItem lastitem = new AuctionTraderItem(); lastitem.BItem = new TraderItem(); foreach (var temp in templ2) { if (temp.BItem.Name == lastitem.BItem.Name && temp.flags == "1") { templ.Remove(temp); templ[templ.IndexOf(lastitem)].count++; continue; } lastitem = temp; } curResp.GetAuctionsResponseP.auctiontraderItem = templ; iweb.Send(CreateBuffer(curResp)); }