private void LobbyError(string message) { GameServerPacket join = new GameServerPacket(StocMessage.JoinGame); join.Write(0U); join.Write((byte)0); join.Write((byte)0); join.Write(0); join.Write(0); join.Write(0); // C++ padding: 5 bytes + 3 bytes = 8 bytes for (int i = 0; i < 3; i++) { join.Write((byte)0); } join.Write(0); join.Write((byte)0); join.Write((byte)0); join.Write((short)0); Send(join); GameServerPacket enter = new GameServerPacket(StocMessage.HsPlayerEnter); enter.Write("[" + message + "]", 20); enter.Write((byte)0); Send(enter); }
private void OnMove(CoreMessage msg) { byte[] raw = msg.Reader.ReadBytes(16); int pc = raw[4]; int pl = raw[5]; int cc = raw[8]; int cl = raw[9]; int cs = raw[10]; int cp = raw[11]; SendToPlayer(msg, cc); GameServerPacket packet = new GameServerPacket(msg.Message); packet.Write(raw); if (!Convert.ToBoolean((cl & ((int)CardLocation.Grave + (int)CardLocation.Overlay))) && Convert.ToBoolean((cl & ((int)CardLocation.Deck + (int)CardLocation.Hand))) || Convert.ToBoolean((cp & (int)CardPosition.FaceDown))) { packet.SetPosition(2); packet.Write(0); } Game.SendToAllBut(packet, cc); if (cl != 0 && (cl & 0x80) == 0 && (cl != pl || pc != cc)) { Game.RefreshSingle(cc, cl, cs); } }
private void OnDraw(CoreMessage msg) { GameServerPacket packet = new GameServerPacket(msg.Message); int player = msg.Reader.ReadByte(); int count = msg.Reader.ReadByte(); packet.Write((byte)player); packet.Write((byte)count); for (int i = 0; i < count; i++) { uint code = msg.Reader.ReadUInt32(); if ((code & 0x80000000) != 0) { packet.Write(code); } else { packet.Write(0); } } SendToPlayer(msg, player); Game.SendToAllBut(packet, player); }
private void ServerMessage(string msg) { string finalmsg = "[Server] " + msg; GameServerPacket packet = new GameServerPacket(StocMessage.Chat); packet.Write((short)PlayerType.Yellow); packet.Write(finalmsg, finalmsg.Length + 1); Send(packet); }
private void OnTagSwap(CoreMessage msg) { GameServerPacket packet = new GameServerPacket(GameMessage.TagSwap); int player = msg.Reader.ReadByte(); int mcount = msg.Reader.ReadByte(); int ecount = msg.Reader.ReadByte(); int epcount = msg.Reader.ReadByte(); int hcount = msg.Reader.ReadByte(); packet.Write((byte)player); packet.Write((byte)mcount); packet.Write((byte)ecount); packet.Write((byte)epcount); packet.Write((byte)hcount); uint id = msg.Reader.ReadUInt32(); packet.Write(id); for (int i = 0; i < hcount; i++) { uint code = msg.Reader.ReadUInt32(); if ((code & 0x80000000) != 0) { packet.Write(code); } else { packet.Write(0); } } for (int i = 0; i < ecount; i++) { uint code = msg.Reader.ReadUInt32(); if ((code & 0x80000000) != 0) { packet.Write(code); } else { packet.Write(0); } } SendToPlayer(msg, player); Game.SendToAllBut(packet, player); Game.RefreshExtra(player); Game.RefreshMonsters(0, 0x81fff, false); Game.RefreshMonsters(1, 0x81fff, false); Game.RefreshSpells(0, 0x681fff, false); Game.RefreshSpells(1, 0x681fff, false); Game.RefreshHand(0, 0x181fff, false); Game.RefreshHand(1, 0x181fff, false); }
private void OnSet(CoreMessage msg) { msg.Reader.ReadBytes(4); byte[] raw = msg.Reader.ReadBytes(4); GameServerPacket packet = new GameServerPacket(GameMessage.Set); packet.Write(0); packet.Write(raw); Game.SendToAll(packet); }
private void OnSelectCard(CoreMessage msg) { GameServerPacket packet = new GameServerPacket(msg.Message); int player = msg.Reader.ReadByte(); packet.Write((byte)player); packet.Write(msg.Reader.ReadBytes(3)); int count = msg.Reader.ReadByte(); packet.Write((byte)count); for (int i = 0; i < count; i++) { int code = msg.Reader.ReadInt32(); int pl = msg.Reader.ReadByte(); int loc = msg.Reader.ReadByte(); int seq = msg.Reader.ReadByte(); int pos = msg.Reader.ReadByte(); packet.Write(pl == player ? code : 0); packet.Write((byte)pl); packet.Write((byte)loc); packet.Write((byte)seq); packet.Write((byte)pos); } Game.WaitForResponse(player); Game.CurPlayers[player].Send(packet); }
public void SendTypeChange() { if(Game==null)return; GameServerPacket packet = new GameServerPacket(StocMessage.TypeChange); packet.Write((byte)(Type + (Game.HostPlayer.Equals(this) ? (int)PlayerType.Host : 0))); Send(packet); }
public void SendTypeChange() { GameServerPacket packet = new GameServerPacket(StocMessage.TypeChange); packet.Write((byte)(Type + (Game.HostPlayer != null && Game.HostPlayer.Equals(this) ? (int)PlayerType.Host : 0))); Send(packet); }
private void SendToAll(CoreMessage msg) { byte[] buffer = msg.CreateBuffer(); GameServerPacket packet = new GameServerPacket(msg.Message); packet.Write(buffer); Game.SendToAll(packet); }
public void ServerMessage(string msg, PlayerType type = PlayerType.Yellow, string head = "[Server] ") { string finalmsg = head + msg; GameServerPacket packet = new GameServerPacket(StocMessage.Chat); packet.Write((short)type); packet.WriteUnicode(finalmsg, finalmsg.Length + 1); Send(packet); }
private void OnUpdateDeck(GameClientPacket packet) { if (Type == (int)PlayerType.Observer) { return; } Deck deck = new Deck(); int main = packet.ReadInt32(); int side = packet.ReadInt32(); for (int i = 0; i < main; i++) { deck.AddMain(packet.ReadInt32()); } for (int i = 0; i < side; i++) { deck.AddSide(packet.ReadInt32()); } if (Game.State == GameState.Lobby) { Deck = deck; Game.IsReady[Type] = false; } else if (Game.State == GameState.Side) { if (Game.IsReady[Type]) { return; } if (!Deck.Check(deck)) { GameServerPacket error = new GameServerPacket(StocMessage.ErrorMsg); error.Write((byte)3); error.Write(0); Send(error); return; } Deck = deck; Game.IsReady[Type] = true; Game.ServerMessage(Name + " is ready."); Send(new GameServerPacket(StocMessage.DuelStart)); Game.MatchSide(); } }
private void OnShuffleHand(CoreMessage msg) { GameServerPacket packet = new GameServerPacket(msg.Message); int player = msg.Reader.ReadByte(); int count = msg.Reader.ReadByte(); packet.Write((byte)player); packet.Write((byte)count); msg.Reader.ReadBytes(count * 4); for (int i = 0; i < count; i++) { packet.Write(0); } SendToPlayer(msg, player); Game.SendToAllBut(packet, player); Game.RefreshHand(player, 0x181fff, false); }
private void SendToPlayer(CoreMessage msg, int player) { if (player != 0 && player != 1) { return; } byte[] buffer = msg.CreateBuffer(); GameServerPacket packet = new GameServerPacket(msg.Message); packet.Write(buffer); Game.CurPlayers[player].Send(packet); }
private void OnConfirmCards(CoreMessage msg) { int player = msg.Reader.ReadByte(); int count = msg.Reader.ReadByte(); msg.Reader.ReadBytes(count * 7); byte[] buffer = msg.CreateBuffer(); GameServerPacket packet = new GameServerPacket(msg.Message); packet.Write(buffer); if ((CardLocation)buffer[7] == CardLocation.Hand) { Game.SendToAll(packet); } else { Game.CurPlayers[player].Send(packet); } }
private void OnHint(CoreMessage msg) { int type = msg.Reader.ReadByte(); int player = msg.Reader.ReadByte(); msg.Reader.ReadInt32(); byte[] buffer = msg.CreateBuffer(); GameServerPacket packet = new GameServerPacket(msg.Message); packet.Write(buffer); switch (type) { case 1: case 2: case 3: case 4: case 5: Game.CurPlayers[player].Send(packet); break; case 6: case 7: case 8: case 9: Game.SendToAllBut(packet, player); break; case 10: if (Game.IsTag) { Game.CurPlayers[player].Send(packet); } else { Game.SendToAll(packet); } break; } }
private void LobbyError(string message) { GameServerPacket join = new GameServerPacket(StocMessage.JoinGame); join.Write(0U); join.Write((byte)0); join.Write((byte)0); join.Write(0); join.Write(0); join.Write(0); // C++ padding: 5 bytes + 3 bytes = 8 bytes for (int i = 0; i < 3; i++) join.Write((byte)0); join.Write(0); join.Write((byte)0); join.Write((byte)0); join.Write((short)0); Send(join); GameServerPacket enter = new GameServerPacket(StocMessage.HsPlayerEnter); enter.Write("[" + message + "]", 20); enter.Write((byte)0); Send(enter); }
private void SendToAll(CoreMessage msg) { byte[] buffer = msg.CreateBuffer(); using(GameServerPacket packet = new GameServerPacket(msg.Message)){ packet.Write(buffer); Game.SendToAll(packet); } }
private void OnDraw(CoreMessage msg) { using(GameServerPacket packet = new GameServerPacket(msg.Message)){ int player = msg.Reader.ReadByte(); int count = msg.Reader.ReadByte(); packet.Write((byte)player); packet.Write((byte)count); for (int i = 0; i < count; i++) { uint code = msg.Reader.ReadUInt32(); if ((code & 0x80000000) != 0) packet.Write(code); else packet.Write(0); } SendToPlayer(msg, player); Game.SendToAllBut(packet, player); } }
private void OnMove(CoreMessage msg) { byte[] raw = msg.Reader.ReadBytes(16); int pc = raw[4]; int pl = raw[5]; int cc = raw[8]; int cl = raw[9]; int cs = raw[10]; int cp = raw[11]; SendToPlayer(msg, cc); using(GameServerPacket packet = new GameServerPacket(msg.Message)){ packet.Write(raw); if (!Convert.ToBoolean((cl & ((int)CardLocation.Grave + (int)CardLocation.Overlay))) && Convert.ToBoolean((cl & ((int)CardLocation.Deck + (int)CardLocation.Hand))) || Convert.ToBoolean((cp & (int)CardPosition.FaceDown))) { packet.SetPosition(2); packet.Write((int)0); } Game.SendToAllBut(packet, cc); } if (cl != 0 && (cl & 0x80) == 0 && (cl != pl || pc != cc)) Game.RefreshSingle(cc, cl, cs); }
private void OnConfirmCards(CoreMessage msg) { int player = msg.Reader.ReadByte(); int count = msg.Reader.ReadByte(); msg.Reader.ReadBytes(count * 7); byte[] buffer = msg.CreateBuffer(); using(GameServerPacket packet = new GameServerPacket(msg.Message)){ packet.Write(buffer); if ((CardLocation)buffer[7] == CardLocation.Hand) Game.SendToAll(packet); else Game.CurPlayers[player].Send(packet); } }
public void RefreshGrave(int player, int flag = 0x81fff, bool useCache = true) { byte[] result = m_duel.QueryFieldCard(player, CardLocation.Grave, flag, useCache); using (GameServerPacket update = new GameServerPacket(GameMessage.UpdateData)) { update.Write((byte)player); update.Write((byte)CardLocation.Grave); update.Write(result); SendToAll(update); } }
public void RefreshExtra(int player, int flag = 0x81fff, bool useCache = true) { byte[] result = m_duel.QueryFieldCard(player, CardLocation.Extra, flag, useCache); using (GameServerPacket update = new GameServerPacket(GameMessage.UpdateData)) { update.Write((byte)player); update.Write((byte)CardLocation.Extra); update.Write(result); CurPlayers[player].Send(update); } }
public void RefreshSingle(int player, int location, int sequence, int flag = 0x781fff) { byte[] result = m_duel.QueryCard(player, location, sequence, flag); if (location == (int)CardLocation.Removed && (result[15] & (int)CardPosition.FaceDown) != 0) return; using (GameServerPacket update = new GameServerPacket(GameMessage.UpdateCard)) { update.Write((byte)player); update.Write((byte)location); update.Write((byte)sequence); update.Write(result); CurPlayers[player].Send(update); if (IsTag) { if ((location & (int)CardLocation.Onfield) != 0) { SendToTeam(update, player); if ((result[15] & (int)CardPosition.FaceUp) != 0) SendToTeam(update, 1 - player); } else { CurPlayers[player].Send(update); if ((location & 0x90) != 0) SendToAllBut(update, player); } } else { if ((location & 0x90) != 0 || ((location & 0x2c) != 0 && (result[15] & (int)CardPosition.FaceUp) != 0)) SendToAllBut(update, player); } } }
private void SendJoinGame(GameSession player) { using (GameServerPacket join = new GameServerPacket(StocMessage.JoinGame)) { join.Write(Banlist == null ? 0U : Banlist.Hash); join.Write((byte)Config.Rule); join.Write((byte)Config.Mode); join.Write(Config.EnablePriority); join.Write(Config.NoCheckDeck); join.Write(Config.NoShuffleDeck); // C++ padding: 5 bytes + 3 bytes = 8 bytes for (int i = 0; i < 3; i++) join.Write((byte)0); join.Write(Config.StartLp); join.Write((byte)Config.StartHand); join.Write((byte)Config.DrawCount); join.Write((short)Config.GameTimer); player.Send(join); } if (State != GameState.Lobby) SendDuelingPlayers(player); }
public void ServerMessage(string msg, PlayerType color = PlayerType.Yellow, bool isNow = true) { string finalmsg = "[Server] " + msg; using (GameServerPacket packet = new GameServerPacket(StocMessage.Chat)) { packet.Write((short)color); packet.WriteUnicode(finalmsg, finalmsg.Length + 1); SendToAll(packet, isNow); } }
public void WaitForResponse(int player) { m_lastresponse = player; CurPlayers[player].State = PlayerState.Response; using (GameServerPacket wait = new GameServerPacket(GameMessage.Waiting)) { SendToAllBut(wait, player); } TimeStart(); using (GameServerPacket packet = new GameServerPacket(StocMessage.TimeLimit)) { packet.Write((byte)player); packet.Write((byte)0); // C++ padding packet.Write((short)m_timelimit[player]); SendToPlayers(packet); } }
public void RefreshHand(int player, int flag = 0x181fff, bool useCache = true) { byte[] result = m_duel.QueryFieldCard(player, CardLocation.Hand, flag | 0x100000, useCache); using (GameServerPacket update = new GameServerPacket(GameMessage.UpdateData)) { update.Write((byte)player); update.Write((byte)CardLocation.Hand); update.Write(result); CurPlayers[player].Send(update); } using (GameServerPacket update = new GameServerPacket(GameMessage.UpdateData)) { update.Write((byte)player); update.Write((byte)CardLocation.Hand); using (MemoryStream ms = new MemoryStream(result)) { BinaryReader reader = new BinaryReader(ms); BinaryWriter writer = new BinaryWriter(ms); while (ms.Position < ms.Length) { int len = reader.ReadInt32(); if (len == 4) { //update.Write(4); continue; } long pos = ms.Position; byte[] raw = reader.ReadBytes(len - 4); if (raw[len - 8] == 0) { ms.Position = pos; writer.Write(new byte[len - 4]); } } writer.Close(); reader.Close(); } update.Write(result); SendToAllBut(update, player); } }
private void OnShuffleHand(CoreMessage msg) { int player = msg.Reader.ReadByte(); int count = msg.Reader.ReadByte(); using(GameServerPacket packet = new GameServerPacket(msg.Message)){ packet.Write((byte)player); packet.Write((byte)count); msg.Reader.ReadBytes(count * 4); for (int i = 0; i < count; i++) packet.Write(0); SendToPlayer(msg, player); Game.SendToAllBut(packet, player); } Game.RefreshHand(player, 0x181fff, false); }
public void RefreshSpells(int player, int flag = 0x681fff, bool useCache = true) { byte[] result = m_duel.QueryFieldCard(player, CardLocation.SpellZone, flag, useCache); using (GameServerPacket update = new GameServerPacket(GameMessage.UpdateData)) { update.Write((byte)player); update.Write((byte)CardLocation.SpellZone); update.Write(result); SendToTeam(update, player); } using (GameServerPacket update = new GameServerPacket(GameMessage.UpdateData)) { update.Write((byte)player); update.Write((byte)CardLocation.SpellZone); using (MemoryStream ms = new MemoryStream(result)) { BinaryReader reader = new BinaryReader(ms); BinaryWriter writer = new BinaryWriter(ms); for (int i = 0; i < 8; i++) { int len = reader.ReadInt32(); if (len == 4) { // update.Write(4); continue; } long pos = ms.Position; byte[] raw = reader.ReadBytes(len - 4); if ((raw[11] & (int)CardPosition.FaceDown) != 0) { ms.Position = pos; writer.Write(new byte[len - 4]); } } reader.Close(); writer.Close(); } update.Write(result); SendToTeam(update, 1 - player); SendToObservers(update); } }
private void OnSet(CoreMessage msg) { msg.Reader.ReadBytes(4); byte[] raw = msg.Reader.ReadBytes(4); using(GameServerPacket packet = new GameServerPacket(GameMessage.Set)){ packet.Write(0); packet.Write(raw); Game.SendToAll(packet); } }
public static void SendTypeChange(this GameSession client) { if(client == null||client.Game==null)return; using(GameServerPacket packet = new GameServerPacket(StocMessage.TypeChange)){ packet.Write((byte)(client.Type + (client.Equals(client.Game.HostPlayer) ? (int)PlayerType.Host : 0))); client.Send(packet); } }
private void OnTagSwap(CoreMessage msg) { int player = msg.Reader.ReadByte(); int mcount = msg.Reader.ReadByte(); int ecount = msg.Reader.ReadByte(); int epcount = msg.Reader.ReadByte(); int hcount = msg.Reader.ReadByte(); using(GameServerPacket packet = new GameServerPacket(GameMessage.TagSwap)){ packet.Write((byte)player); packet.Write((byte)mcount); packet.Write((byte)ecount); packet.Write((byte)epcount); packet.Write((byte)hcount); uint id = msg.Reader.ReadUInt32(); packet.Write(id); for (int i = 0; i < hcount; i++) { uint code = msg.Reader.ReadUInt32(); if ((code & 0x80000000) != 0) packet.Write(code); else packet.Write(0); } for (int i = 0; i < ecount; i++) { uint code = msg.Reader.ReadUInt32(); if ((code & 0x80000000) != 0) packet.Write(code); else packet.Write(0); } SendToPlayer(msg, player); Game.SendToAllBut(packet, player); } Game.RefreshExtra(player); Game.RefreshMonsters(0, 0x81fff, false); Game.RefreshMonsters(1, 0x81fff, false); Game.RefreshSpells(0, 0x681fff, false); Game.RefreshSpells(1, 0x681fff, false); Game.RefreshHand(0, 0x181fff, false); Game.RefreshHand(1, 0x181fff, false); }
public static void OnChat(GameSession client, GameClientPacket packet){ if (!client.IsAuthentified){ return; } string msg = packet.ReadUnicode(256); if(client.Game==null){ return; } if(!client.OnChatCommand(msg)){ using(GameServerPacket chat = new GameServerPacket(StocMessage.Chat)){ chat.Write((short)client.Type); chat.WriteUnicode(msg, msg.Length + 1); client.Game.SendToAllBut(chat, client); } } }
private void SendToPlayer(CoreMessage msg, int player) { if (player != 0 && player != 1) return; byte[] buffer = msg.CreateBuffer(); using(GameServerPacket packet = new GameServerPacket(msg.Message)){ packet.Write(buffer); Game.CurPlayers[player].Send(packet); } }
public static void OnUpdateDeck(GameSession client, GameClientPacket packet){ if (client.Game==null||client.Type == (int)PlayerType.Observer||client.Type == (int)PlayerType.Undefined) return; Deck deck = new Deck(); int main = packet.ReadInt32(); int side = packet.ReadInt32(); for (int i = 0; i < main; i++) deck.AddMain(packet.ReadInt32()); for (int i = 0; i < side; i++) deck.AddSide(packet.ReadInt32()); if (client.Game.State == GameState.Lobby) { client.Deck = deck; client.Game.IsReady[client.Type] = false; } else if (client.Game.State == GameState.Side) { if (client.Game.IsReady[client.Type]) return; if (!client.Deck.Check(deck)) { using(GameServerPacket error = new GameServerPacket(StocMessage.ErrorMsg)){ error.Write((byte)3); error.Write(0); client.Send(error); } return; } client.Deck = deck; client.Game.IsReady[client.Type] = true; client.Game.ServerMessage(string.Format(Messages.MSG_READY, client.Name)); client.Send(GameServerPacket.EmtryMessage(StocMessage.DuelStart)); client.Game.MatchSide(); } }
private void OnUpdateDeck(GameClientPacket packet) { if (Type == (int)PlayerType.Observer) return; Deck deck = new Deck(); int main = packet.ReadInt32(); int side = packet.ReadInt32(); for (int i = 0; i < main; i++) deck.AddMain(packet.ReadInt32()); for (int i = 0; i < side; i++) deck.AddSide(packet.ReadInt32()); if (Game.State == GameState.Lobby) { Deck = deck; Game.IsReady[Type] = false; } else if (Game.State == GameState.Side) { if (Game.IsReady[Type]) return; if (!Deck.Check(deck)) { GameServerPacket error = new GameServerPacket(StocMessage.ErrorMsg); error.Write((byte)3); error.Write(0); Send(error); return; } Deck = deck; Game.IsReady[Type] = true; Game.ServerMessage(Name + " is ready."); Send(new GameServerPacket(StocMessage.DuelStart)); Game.MatchSide(); } }
public static void LobbyError(this GameSession client, string message,bool isNow=true) { using(GameServerPacket join = new GameServerPacket(StocMessage.JoinGame)){ join.Write(0U); join.Write((byte)0); join.Write((byte)0); join.Write(0); join.Write(0); join.Write(0); // C++ padding: 5 bytes + 3 bytes = 8 bytes for (int i = 0; i < 3; i++) join.Write((byte)0); join.Write(0); join.Write((byte)0); join.Write((byte)0); join.Write((short)0); client.Send(join, false); } using(GameServerPacket enter = new GameServerPacket(StocMessage.HsPlayerEnter)){ enter.WriteUnicode("[err]" + message, 20); enter.Write((byte)0); client.Send(enter, isNow); } }
public static GameServerPacket getMessage(string finalmsg,PlayerType type=PlayerType.Yellow){ GameServerPacket packet = new GameServerPacket(StocMessage.Chat); packet.Write((short)type); packet.WriteUnicode(finalmsg, finalmsg.Length + 1); return packet; }
private void OnHint(CoreMessage msg) { int type = msg.Reader.ReadByte(); int player = msg.Reader.ReadByte(); msg.Reader.ReadInt32(); byte[] buffer = msg.CreateBuffer(); using(GameServerPacket packet = new GameServerPacket(msg.Message)){ packet.Write(buffer); switch (type) { case 1: case 2: case 3: case 4: case 5: Game.CurPlayers[player].Send(packet); break; case 6: case 7: case 8: case 9: Game.SendToAllBut(packet, player); break; case 10: if (Game.IsTag) Game.CurPlayers[player].Send(packet); else Game.SendToAll(packet); break; } } }
public void EndDuel(bool force) { if (State == GameState.Duel) { if (!Replay.Disabled) { Replay.End(); byte[] replayData = Replay.GetFile(); GameServerPacket packet = new GameServerPacket(StocMessage.Replay); packet.Write(replayData); SendToPlayers(packet); //SendToAll(packet); } State = GameState.End; m_duel.End(); DuleTimer.Stop(); } if (m_swapped) { m_swapped = false; GameSession temp = Players[0]; Players[0] = Players[1]; Players[1] = temp; Players[0].Type = 0; Players[1].Type = 1; } if (IsMatch && !force && !MatchIsEnd()) { IsReady[0] = false; IsReady[1] = false; ServerMessage(Messages.MSG_SIDE); State = GameState.Side; GameTimer.StartSideTimer(); // Server.OnPlayEvent(PlayerStatu.PlayerSide, Players); using (GameServerPacket p = new GameServerPacket(StocMessage.ChangeSide)) { SendToPlayers(p); } using (GameServerPacket p = new GameServerPacket(StocMessage.WaitingSide)) { SendToObservers(p); } } else { if (State == GameState.Side) { //Logger.WriteLine("side is lose"); State = GameState.End; GameSession pl = null; try { if (Players[0] != null) { pl = (Players[0].IsConnected) ? Players[1] : Players[0]; } } catch { } if (pl != null) { // && pl.Type != (int)PlayerType.Observer Surrender(pl, 4, true); } } End(); } }
private void OnSelectCard(CoreMessage msg) { using(GameServerPacket packet = new GameServerPacket(msg.Message)){ int player = msg.Reader.ReadByte(); packet.Write((byte)player); packet.Write(msg.Reader.ReadBytes(3)); int count = msg.Reader.ReadByte(); packet.Write((byte)count); for (int i = 0; i < count; i++) { int code = msg.Reader.ReadInt32(); int pl = msg.Reader.ReadByte(); int loc = msg.Reader.ReadByte(); int seq = msg.Reader.ReadByte(); int pos = msg.Reader.ReadByte(); packet.Write(pl == player ? code : 0); packet.Write((byte)pl); packet.Write((byte)loc); packet.Write((byte)seq); packet.Write((byte)pos); } Game.WaitForResponse(player); Game.CurPlayers[player].Send(packet); } }
public static void ServerMessage(this GameSession client, string msg, PlayerType type=PlayerType.Yellow,bool isNow=true) { string finalmsg = "[Server] " + msg; using(GameServerPacket packet = new GameServerPacket(StocMessage.Chat)){ packet.Write((short)type); packet.WriteUnicode(finalmsg, finalmsg.Length + 1); client.Send(packet, isNow); } }
public void ServerMessage(string msg, PlayerType type=PlayerType.Yellow, string head="[Server] ") { string finalmsg = head + msg; GameServerPacket packet = new GameServerPacket(StocMessage.Chat); packet.Write((short)type); packet.WriteUnicode(finalmsg, finalmsg.Length + 1); Send(packet); }