Beispiel #1
0
        public void InterHall(Client client, bool reconnect)
        {
            try
            {
                //update user profile
                //bring to hall
                bool proceed = client.GetProfile(!reconnect);
                if (!proceed)
                {
                    return;
                }

                clientList.TryAdd(client.UserID, client.Profile.NickName);
                //更新到form1
                Dictionary <int, string> client_list = clientList.ToDictionary(entry => entry.Key, entry => entry.Value);
                UpdateUsers(client_list);

                UId2ClientTable.TryGetValue(client.UserID, out Client temp);

                MyData data = new MyData();
                if (!reconnect)
                {
                    //发送当前已登录的其他玩家信息和游戏房间信息
                    Dictionary <int, RoomInfoStruct> ds = RoomList.Instance().GetRoomList();
                    data = new MyData
                    {
                        Description = PacketDescription.Hall2Cient,
                        Protocol    = Protocol.GetProfile,
                        Body        = new List <string> {
                            JsonUntity.Dictionary2Json(client_list), JsonUntity.Object2Json(ds)
                        }
                    };
                    client.SendProfileReply(data);
                }

                //通知其他客户端更新
                data = new MyData()
                {
                    Description = PacketDescription.Hall2Cient,
                    Protocol    = Protocol.UpdateHallJoin,
                    Body        = new List <string> {
                        client.UserID.ToString(), client.Profile.NickName, "0"
                    }
                };

                List <Client> clients = new List <Client>(UId2ClientTable.Values);
                foreach (Client other in clients)
                {
                    if (other != client)
                    {
                        other.SendProfileReply(data);
                    }
                }
            }
            catch (Exception e)
            {
                LogHelper.WriteLog(null, e);
                Debug(string.Format("error on inter hall {0} {1}", e.Message, e.TargetSite));
            }
        }
Beispiel #2
0
 public virtual void CheckBigKingdoms(Room room)
 {
     room.DoBroadcastNotify(CommandType.S_COMMAND_LOG_EVENT, new List <string> {
         GameEventType.S_GAME_EVENT_BIG_KINGDOM.ToString(),
         JsonUntity.Object2Json(RoomLogic.GetBigKingdoms(room))
     });
 }
        public static byte[] Data2byte(MyData data)
        {
            byte[] rawData = Encoding.UTF8.GetBytes(JsonUntity.Object2Json(data));
            using (MemoryStream ms = new MemoryStream())
            {
                GZipOutputStream compressedzipStream = new GZipOutputStream(ms);

                compressedzipStream.Write(rawData, 0, rawData.Length);
                compressedzipStream.Close();
                byte[] dataBody = ms.ToArray();
                ms.Close();
                return(dataBody);
            }
        }
        public static byte[] data2byte(MyData data, string Key)
        {
            //var commandData = new byte[4];//协议命令只占4位
            var commandData = Encoding.UTF8.GetBytes(Key);//协议命令只占4位,如果占的位数长过协议,那么协议解析肯定会出错的

            byte[] dataBody = System.Text.Encoding.UTF8.GetBytes(JsonUntity.Object2Json <MyData>(data));
            var    dataLen  = BitConverter.GetBytes(dataBody.Length);//int类型占4位,根据协议这里也只能4位,否则会出错


            var sendData = new byte[8 + dataBody.Length];//命令加内容长度为8

            // +-------+---+-------------------------------+
            // |request| l |                               |
            // | name  | e |    request body               |
            // |  (4)  | n |                               |
            // |       |(4)|                               |
            // +-------+---+-------------------------------+

            Array.ConstrainedCopy(commandData, 0, sendData, 0, 4);
            Array.ConstrainedCopy(dataLen, 0, sendData, 4, 4);
            Array.ConstrainedCopy(dataBody, 0, sendData, 8, dataBody.Length);

            return(sendData);
        }
        public override void Assign(Room room)
        {
            System.Threading.Thread.Sleep(1000);
            //先确定两边主公
            foreach (Player lord in room.Players)
            {
                if (lord.GetRoleEnum() == Player.PlayerRole.Lord)
                {
                    if (lord.Camp == Game3v3Camp.S_CAMP_COOL)
                    {
                        lord.General1 = lord.ActualGeneral1 = "caocao_jx";
                    }
                    else
                    {
                        lord.General1 = lord.ActualGeneral1 = "yuanshao";
                    }

                    General lord_gen = Engine.GetGeneral(lord.General1, room.Setting.GameMode);
                    lord.PlayerGender   = lord_gen.GeneralGender;
                    lord.Kingdom        = General.GetKingdom(lord_gen.Kingdom[0]);
                    lord.General1Showed = true;
                    room.BroadcastProperty(lord, "General1");
                    room.BroadcastProperty(lord, "PlayerGender");
                    room.NotifyProperty(room.GetClient(lord), lord, "ActualGeneral1");
                    room.BroadcastProperty(lord, "Kingdom");
                    room.BroadcastProperty(lord, "General1Showed");
                    foreach (string skill in Engine.GetGeneralSkills(lord.General1, Name, true))
                    {
                        room.AddPlayerSkill(lord, skill);
                        Skill s = Engine.GetSkill(skill);
                        if (s != null && s.SkillFrequency == Frequency.Limited && !string.IsNullOrEmpty(s.LimitMark))
                        {
                            room.SetPlayerMark(lord, s.LimitMark, 1);
                        }
                    }

                    room.SendPlayerSkillsToOthers(lord, true);

                    //技能预亮
                    lord.SetSkillsPreshowed("hd");
                    room.NotifyPlayerPreshow(lord);
                    room.HandleUsedGeneral(lord.General1);
                }
            }

            System.Threading.Thread.Sleep(1000);

            //为其余玩家分配武将
            List <string> generals = room.Generals, warms = new List <string>(), cools = new List <string>();

            generals.Remove("caocao_jx"); generals.Remove("yuanshao");
            foreach (string general in generals)
            {
                General gen = Engine.GetGeneral(general, room.Setting.GameMode);
                if (gen.Kingdom[0] == General.KingdomENUM.Wei)
                {
                    cools.Add(general);
                }
                else
                {
                    warms.Add(general);
                }
            }
            Shuffle.shuffle(ref warms);
            Shuffle.shuffle(ref cools);

            Dictionary <Player, List <string> > options = new Dictionary <Player, List <string> >();

            foreach (Player player in room.Players)
            {
                if (player.GetRoleEnum() == Player.PlayerRole.Lord)
                {
                    continue;
                }
                List <string> choices = new List <string>();

                if (player.Camp == Game3v3Camp.S_CAMP_COOL)
                {
                    choices.Add(cools[0]);
                    cools.RemoveAt(0);
                    choices.Add(cools[0]);
                    cools.RemoveAt(0);
                }
                else
                {
                    choices.Add(warms[0]);
                    warms.RemoveAt(0);
                    choices.Add(warms[0]);
                    warms.RemoveAt(0);
                }

                options.Add(player, choices);
            }

            //玩家选将
            List <Interactivity> receivers = new List <Interactivity>();
            List <Player>        players   = new List <Player>();

            foreach (Player player in options.Keys)
            {
                if (player.GetRoleEnum() == Player.PlayerRole.Lord)
                {
                    continue;
                }
                player.SetTag("generals", JsonUntity.Object2Json(options[player]));
                List <string> args = new List <string>
                {
                    player.Name,
                    string.Empty,
                    JsonUntity.Object2Json(options[player]),
                    true.ToString(),
                    true.ToString(),
                    false.ToString()
                };
                Interactivity client = room.GetInteractivity(player);
                if (client != null && !receivers.Contains(client))
                {
                    client.CommandArgs = args;
                    receivers.Add(client);
                }
                players.Add(player);
            }

            Countdown countdown = new Countdown
            {
                Max  = room.Setting.GetCommandTimeout(CommandType.S_COMMAND_CHOOSE_GENERAL, ProcessInstanceType.S_CLIENT_INSTANCE),
                Type = Countdown.CountdownType.S_COUNTDOWN_USE_SPECIFIED
            };

            room.NotifyMoveFocus(players, countdown);
            room.DoBroadcastRequest(receivers, CommandType.S_COMMAND_CHOOSE_GENERAL);
            room.DoBroadcastNotify(CommandType.S_COMMAND_UNKNOWN, new List <string> {
                false.ToString()
            });

            //按武将强度排序
            List <string> prefer_cools = new List <string> {
                "xunyou", "xunyu", "chengyu", "guojia", "liuye", "caoren", "guanyu_sp", "xuhuang_jx", "zhangliao_jx",
                "hanhaoshihuan", "yujin", "caohong", "manchong", "litong", "zangba"
            };
            List <string> prefer_warms = new List <string> {
                "chunyuqiong", "xunchen", "shenpei", "liubei_gd", "chenlin_gd", "jvshou", "xuyou", "zhanghe_gd", "gaolan",
                "guotupangji", "tianfeng", "yanliangwenchou", "eryuan", "xinpi_gd", "erlv"
            };

            //给AI和超时的玩家自动选择武将
            foreach (Player player in options.Keys)
            {
                player.RemoveTag("generals");
                if (string.IsNullOrEmpty(player.General1))
                {
                    string        generalName = string.Empty;
                    List <string> reply       = room.GetInteractivity(player)?.ClientReply;
                    bool          success     = true;
                    if (reply == null || reply.Count == 0 || string.IsNullOrEmpty(reply[0]))
                    {
                        success = false;
                    }
                    else
                    {
                        generalName = reply[0];
                    }

                    if (!success || (!options[player].Contains(generalName) && room.GetClient(player).UserRight < 3) ||
                        (player.Camp == Game3v3Camp.S_CAMP_COOL && Engine.GetGeneral(generalName, room.Setting.GameMode).Kingdom[0] != General.KingdomENUM.Wei) ||
                        (player.Camp == Game3v3Camp.S_CAMP_WARM && Engine.GetGeneral(generalName, room.Setting.GameMode).Kingdom[0] != General.KingdomENUM.Qun))
                    {
                        if (player.Status == "bot")
                        {
                            List <string> prefers;
                            if (player.Camp == Game3v3Camp.S_CAMP_COOL)
                            {
                                prefers = prefer_cools;
                            }
                            else
                            {
                                prefers = prefer_warms;
                            }

                            options[player].Sort((x, y) => { return(prefers.IndexOf(x) < prefers.IndexOf(y) ? -1 : 1); });
                        }
                        generalName = options[player][0];
                    }
                    player.General1       = generalName;
                    player.ActualGeneral1 = generalName;
                    player.Kingdom        = General.GetKingdom(Engine.GetGeneral(generalName, room.Setting.GameMode).Kingdom[0]);
                    player.General1Showed = true;
                }

                room.BroadcastProperty(player, "General1");
                room.NotifyProperty(room.GetClient(player), player, "ActualGeneral1");
                room.BroadcastProperty(player, "Kingdom");
                room.BroadcastProperty(player, "General1Showed");
                player.PlayerGender = Engine.GetGeneral(player.General1, room.Setting.GameMode).GeneralGender;
                room.BroadcastProperty(player, "PlayerGender");

                player.SetSkillsPreshowed("hd");
                room.NotifyPlayerPreshow(player);
                List <string> names = new List <string> {
                    player.General1
                };
                room.SetTag(player.Name, names);
                room.HandleUsedGeneral(player.General1);
            }
        }
Beispiel #6
0
        public override void Assign(Room room)
        {
            Thread.Sleep(1000);

            //分配武将
            AssignGeneralsForPlayers(room, out Dictionary <Player, List <string> > options);
            //武将预览
            foreach (Player p in room.Players)
            {
                List <string> gongxinArgs = new List <string> {
                    string.Empty, JsonUntity.Object2Json(options[p]), string.Empty, string.Empty, "false"
                };
                room.DoNotify(room.GetClient(p), CommandType.S_COMMAND_VIEW_GENERALS, gongxinArgs);
            }

            List <Interactivity> receivers = new List <Interactivity>();
            List <Player>        lords     = new List <Player>();

            foreach (Client client in room.Clients)
            {
                List <string> args = new List <string> {
                    string.Empty, "userdefine:getlandlord", null
                };
                Interactivity inter = room.GetInteractivity(client.UserID);
                if (inter != null)
                {
                    inter.CommandArgs = args;
                    receivers.Add(inter);
                }
            }
            room.DoBroadcastRequest(receivers, CommandType.S_COMMAND_INVOKE_SKILL);
            room.DoBroadcastNotify(CommandType.S_COMMAND_UNKNOWN, new List <string> {
                false.ToString()
            });

            foreach (Player player in room.Players)
            {
                Interactivity client = room.GetInteractivity(player);
                if (client != null && client.IsClientResponseReady && receivers.Contains(client))
                {
                    List <string> invoke = client.ClientReply;
                    if (invoke != null && invoke.Count > 0 && bool.TryParse(invoke[0], out bool success) && success)
                    {
                        lords.Add(player);
                    }
                }
            }

            bool get = true;

            if (lords.Count == 0)
            {
                get   = false;
                lords = new List <Player>(room.Players);
            }
            Player lord = null;

            Shuffle.shuffle(ref lords);
            lord = lords[0];

            if (get)
            {
                LogMessage log = new LogMessage
                {
                    Type = "#get_landlord",
                    From = lord.Name
                };
                room.SendLog(log);
            }
            else
            {
                LogMessage log = new LogMessage
                {
                    Type = "#distribute_landlord",
                    From = lord.Name
                };
                room.SendLog(log);
            }

            foreach (Player p in room.Players)
            {
                if (p == lord)
                {
                    p.Camp = Game3v3Camp.S_CAMP_COOL;
                    p.Role = "lord";
                    room.BroadcastProperty(p, "Camp");
                }
                else
                {
                    p.Role = "rebel";
                }
                room.BroadcastProperty(p, "Role");
            }

            //地主增加2框
            List <string> generals = (List <string>)room.GetTag(Name);

            for (int i = 0; i < 2; i++)
            {
                Shuffle.shuffle(ref generals);
                options[lord].Add(generals[0]);
                generals.RemoveAt(0);
            }

            //选将
            receivers.Clear();
            List <Player> players = new List <Player>();

            foreach (Player player in options.Keys)
            {
                player.SetTag("generals", JsonUntity.Object2Json(options[player]));
                List <string> args = new List <string>
                {
                    player.Name,
                    string.Empty,
                    JsonUntity.Object2Json(options[player]),
                    true.ToString(),
                    true.ToString(),
                    false.ToString()
                };
                Interactivity client = room.GetInteractivity(player);
                if (client != null)
                {
                    client.CommandArgs = args;
                    receivers.Add(client);
                }
                players.Add(player);
            }

            Countdown countdown = new Countdown
            {
                Max  = room.Setting.GetCommandTimeout(CommandType.S_COMMAND_CHOOSE_GENERAL, ProcessInstanceType.S_CLIENT_INSTANCE),
                Type = Countdown.CountdownType.S_COUNTDOWN_USE_SPECIFIED
            };

            room.NotifyMoveFocus(players, countdown);
            room.DoBroadcastRequest(receivers, CommandType.S_COMMAND_CHOOSE_GENERAL);
            room.DoBroadcastNotify(CommandType.S_COMMAND_UNKNOWN, new List <string> {
                false.ToString()
            });

            //给AI和超时的玩家自动选择武将
            foreach (Player player in options.Keys)
            {
                player.RemoveTag("generals");
                if (string.IsNullOrEmpty(player.General1))
                {
                    string        generalName = string.Empty;
                    Interactivity client      = room.GetInteractivity(player);
                    List <string> reply       = client?.ClientReply;
                    bool          success     = true;
                    if (reply == null || reply.Count == 0 || string.IsNullOrEmpty(reply[0]))
                    {
                        success = false;
                    }
                    else
                    {
                        generalName = reply[0];
                    }

                    if (!success || (!options[player].Contains(generalName) && room.GetClient(player).UserRight < 3))
                    {
                        TrustedAI ai = room.GetAI(player);
                        if (ai != null && ai is StupidAI)
                        {
                            generalName = GeneralSelector.GetGeneral(room, options[player], player.GetRoleEnum(), player);
                        }
                        else
                        {
                            generalName = options[player][0];
                        }
                    }

                    player.General1       = generalName;
                    player.ActualGeneral1 = generalName;
                    player.Kingdom        = Engine.GetGeneral(generalName, room.Setting.GameMode).Kingdom;
                    player.General1Showed = true;
                }

                room.BroadcastProperty(player, "General1");
                room.NotifyProperty(room.GetClient(player), player, "ActualGeneral1");
                room.BroadcastProperty(player, "Kingdom");
                room.BroadcastProperty(player, "General1Showed");
                player.PlayerGender = Engine.GetGeneral(player.General1, room.Setting.GameMode).GeneralGender;
                room.BroadcastProperty(player, "PlayerGender");

                player.SetSkillsPreshowed("hd");
                room.NotifyPlayerPreshow(player);
                List <string> names = new List <string> {
                    player.General1
                };
                room.SetTag(player.Name, names);
                room.HandleUsedGeneral(player.General1);
            }

            //神将选国籍
            string        choice  = "wei+qun+shu+wu";
            List <string> prompts = new List <string> {
                "@choose-kingdom"
            };

            receivers.Clear();
            players.Clear();
            foreach (Player player in room.Players)
            {
                if (player.Kingdom != "god")
                {
                    continue;
                }
                List <string> args = new List <string>
                {
                    player.Name,
                    "Kingdom",
                    choice,
                    JsonUntity.Object2Json(prompts)
                };
                Interactivity client = room.GetInteractivity(player);
                if (client != null && !receivers.Contains(client))
                {
                    client.CommandArgs = args;
                    receivers.Add(client);
                }
                players.Add(player);
            }

            countdown = new Countdown
            {
                Max  = room.Setting.GetCommandTimeout(CommandType.S_COMMAND_MULTIPLE_CHOICE, ProcessInstanceType.S_CLIENT_INSTANCE),
                Type = Countdown.CountdownType.S_COUNTDOWN_USE_SPECIFIED
            };
            room.NotifyMoveFocus(players, countdown);
            room.DoBroadcastRequest(receivers, CommandType.S_COMMAND_MULTIPLE_CHOICE);
            room.DoBroadcastNotify(CommandType.S_COMMAND_UNKNOWN, new List <string> {
                false.ToString()
            });

            foreach (Player player in players)
            {
                string        answer        = string.Empty;
                Interactivity interactivity = room.GetInteractivity(player);
                if (interactivity != null)
                {
                    List <string> clientReply = interactivity.ClientReply;
                    if (clientReply != null && clientReply.Count > 0)
                    {
                        answer = clientReply[0];
                    }
                }

                List <string> choices = new List <string>(choice.Split('+'));
                if (string.IsNullOrEmpty(answer) || !choices.Contains(answer))
                {
                    Shuffle.shuffle(ref choices);
                    answer = choices[0];
                }
                player.Kingdom = answer;
                room.BroadcastProperty(player, "Kingdom");
            }
        }
Beispiel #7
0
        public override void Assign(Room room)
        {
            //确定身份
            Player lord = room.Players[0];

            lord.Role = "lord";
            room.BroadcastProperty(lord, "Role");

            List <string> roles = new List <string> {
                "loyalist", "rebel", "renegade"
            };

            if (room.Players.Count == 5)
            {
                roles.Add("rebel");
            }
            else if (room.Players.Count == 6)
            {
                roles.Add("rebel");
                roles.Add("rebel");
            }
            else if (room.Players.Count == 7)
            {
                roles.Add("loyalist");
                roles.Add("rebel");
                roles.Add("rebel");
            }
            else if (room.Players.Count == 8)
            {
                roles.Add("loyalist");
                roles.Add("rebel");
                roles.Add("rebel");
                roles.Add("rebel");
            }
            List <Player> all = new List <Player>(room.Players);

            all.Remove(lord);

            //点选内奸的玩家
            List <Player> to_choose = new List <Player>();

            foreach (Player p in room.Players)
            {
                if (p.GetRoleEnum() != PlayerRole.Lord && room.GetClient(p).RoleReserved == "renegade")
                {
                    to_choose.Add(p);
                }
            }

            if (to_choose.Count > 0)
            {
                List <string> renegades = roles.FindAll(t => t == "renegade");
                Shuffle.shuffle(ref to_choose);
                for (int i = 0; i < Math.Min(to_choose.Count, renegades.Count); i++)
                {
                    to_choose[i].Role = "renegade";
                    roles.Remove("renegade");
                    all.Remove(to_choose[i]);
                }
            }

            //点选忠臣的玩家
            to_choose.Clear();
            foreach (Player p in room.Players)
            {
                if (p.GetRoleEnum() != PlayerRole.Lord && room.GetClient(p).RoleReserved == "loyalist")
                {
                    to_choose.Add(p);
                }
            }

            if (to_choose.Count > 0)
            {
                List <string> loyalists = roles.FindAll(t => t == "loyalist");
                Shuffle.shuffle(ref to_choose);
                for (int i = 0; i < Math.Min(loyalists.Count, to_choose.Count); i++)
                {
                    to_choose[i].Role = "loyalist";
                    roles.Remove("loyalist");
                    all.Remove(to_choose[i]);
                }
            }
            //点选反贼的玩家
            to_choose.Clear();
            foreach (Player p in room.Players)
            {
                if (p.GetRoleEnum() != PlayerRole.Lord && room.GetClient(p).RoleReserved == "rebel")
                {
                    to_choose.Add(p);
                }
            }

            if (to_choose.Count > 0)
            {
                List <string> rebels = roles.FindAll(t => t == "rebel");
                Shuffle.shuffle(ref to_choose);
                for (int i = 0; i < Math.Min(rebels.Count, to_choose.Count); i++)
                {
                    to_choose[i].Role = "rebel";
                    roles.Remove("rebel");
                    all.Remove(to_choose[i]);
                }
            }

            //为剩余玩家随机身份
            if (roles.Count > 0)
            {
                Shuffle.shuffle(ref roles);
                for (int i = 0; i < all.Count; i++)
                {
                    all[i].Role = roles[i];
                }
            }

            //通知各玩家身份
            foreach (Player p in room.Players)
            {
                room.NotifyProperty(room.GetClient(p), p, "Role");
            }

            room.UpdateStateItem();

            Thread.Sleep(2500);

            AssignGeneralsForPlayers(room, out Dictionary <Player, List <string> > options);
            //主公选将
            string lord_general = room.AskForGeneral(lord, new List <string>(options[lord]), string.Empty, true, "gamerule", null, true);

            lord.General1       = lord_general;
            lord.ActualGeneral1 = lord_general;
            General lord_gen = Engine.GetGeneral(lord_general, room.Setting.GameMode);

            lord.PlayerGender   = lord_gen.GeneralGender;
            lord.Kingdom        = lord_gen.Kingdom;
            lord.General1Showed = true;
            room.BroadcastProperty(lord, "General1");
            room.BroadcastProperty(lord, "PlayerGender");
            room.NotifyProperty(room.GetClient(lord), lord, "ActualGeneral1");
            room.BroadcastProperty(lord, "Kingdom");
            room.BroadcastProperty(lord, "General1Showed");

            foreach (string skill in Engine.GetGeneralSkills(lord_general, Name, true))
            {
                room.AddPlayerSkill(lord, skill);
                Skill s = Engine.GetSkill(skill);
                if (skill != null && s.SkillFrequency == Frequency.Limited && !string.IsNullOrEmpty(s.LimitMark))
                {
                    room.SetPlayerMark(lord, s.LimitMark, 1);
                }
            }
            room.SendPlayerSkillsToOthers(lord, true);

            //技能预亮
            lord.SetSkillsPreshowed("hd");
            room.NotifyPlayerPreshow(lord);
            //主公神将选国籍
            string        choice  = "wei+qun+shu+wu";
            List <string> prompts = new List <string> {
                "@choose-kingdom"
            };

            if (lord.Kingdom == "god")
            {
                lord.Kingdom = room.AskForChoice(lord, "Kingdom", choice, prompts);
                room.BroadcastProperty(lord, "Kingdom");
            }

            //其他玩家选将
            List <Client> receivers = new List <Client>();
            List <Player> players   = new List <Player>();

            foreach (Player player in options.Keys)
            {
                if (player.GetRoleEnum() == PlayerRole.Lord)
                {
                    continue;
                }
                player.SetTag("generals", JsonUntity.Object2Json(options[player]));
                List <string> args = new List <string>
                {
                    player.Name,
                    string.Empty,
                    JsonUntity.Object2Json(options[player]),
                    true.ToString(),
                    true.ToString(),
                    false.ToString()
                };
                Client client = room.GetClient(player);
                if (client != null && !receivers.Contains(client))
                {
                    client.CommandArgs = args;
                    receivers.Add(client);
                }
                players.Add(player);
            }

            Countdown countdown = new Countdown
            {
                Max  = room.Setting.GetCommandTimeout(CommandType.S_COMMAND_CHOOSE_GENERAL, ProcessInstanceType.S_CLIENT_INSTANCE),
                Type = Countdown.CountdownType.S_COUNTDOWN_USE_SPECIFIED
            };

            room.NotifyMoveFocus(players, countdown);
            room.DoBroadcastRequest(receivers, CommandType.S_COMMAND_CHOOSE_GENERAL);
            room.DoBroadcastNotify(CommandType.S_COMMAND_UNKNOWN, new List <string> {
                false.ToString()
            });

            //给AI和超时的玩家自动选择武将
            foreach (Player player in options.Keys)
            {
                player.RemoveTag("generals");
                if (string.IsNullOrEmpty(player.General1))
                {
                    string        generalName = string.Empty;
                    Client        client      = room.GetClient(player);
                    List <string> reply       = client?.ClientReply;
                    bool          success     = true;
                    if (reply == null || reply.Count == 0 || string.IsNullOrEmpty(reply[0]))
                    {
                        success = false;
                    }
                    else
                    {
                        generalName = reply[0];
                    }

                    if (!success || (!options[player].Contains(Engine.GetMainGeneral(generalName)) && room.GetClient(player).UserRight < 3))
                    {
                        generalName = options[player][0];
                    }

                    player.General1       = generalName;
                    player.ActualGeneral1 = generalName;
                    player.Kingdom        = Engine.GetGeneral(generalName, room.Setting.GameMode).Kingdom;
                    player.General1Showed = true;
                }

                room.BroadcastProperty(player, "General1");
                room.NotifyProperty(room.GetClient(player), player, "ActualGeneral1");
                room.BroadcastProperty(player, "Kingdom");
                room.BroadcastProperty(player, "General1Showed");
                player.PlayerGender = Engine.GetGeneral(player.General1, room.Setting.GameMode).GeneralGender;
                room.BroadcastProperty(player, "PlayerGender");

                player.SetSkillsPreshowed("hd");
                room.NotifyPlayerPreshow(player);
                List <string> names = new List <string> {
                    player.General1
                };
                room.SetTag(player.Name, names);
                room.HandleUsedGeneral(player.General1);
            }

            //非主公神将选国籍
            receivers.Clear();
            players.Clear();
            foreach (Player player in room.Players)
            {
                if (player.Kingdom != "god")
                {
                    continue;
                }
                List <string> args = new List <string>
                {
                    player.Name,
                    "Kingdom",
                    choice,
                    JsonUntity.Object2Json(prompts)
                };
                Client client = room.GetClient(player);
                if (client != null && !receivers.Contains(client))
                {
                    client.CommandArgs = args;
                    receivers.Add(client);
                }
                players.Add(player);
            }

            countdown = new Countdown
            {
                Max  = room.Setting.GetCommandTimeout(CommandType.S_COMMAND_MULTIPLE_CHOICE, ProcessInstanceType.S_CLIENT_INSTANCE),
                Type = Countdown.CountdownType.S_COUNTDOWN_USE_SPECIFIED
            };
            room.NotifyMoveFocus(players, countdown);
            room.DoBroadcastRequest(receivers, CommandType.S_COMMAND_MULTIPLE_CHOICE);
            room.DoBroadcastNotify(CommandType.S_COMMAND_UNKNOWN, new List <string> {
                false.ToString()
            });

            foreach (Player player in players)
            {
                string        answer      = string.Empty;
                List <string> clientReply = room.GetClient(player).ClientReply;
                if (clientReply != null && clientReply.Count > 0)
                {
                    answer = clientReply[0];
                }
                List <string> choices = new List <string>(choice.Split('+'));

                if (string.IsNullOrEmpty(answer) || !choices.Contains(answer))
                {
                    Shuffle.shuffle(ref choices);
                    answer = choices[0];
                }
                player.Kingdom = answer;
                room.BroadcastProperty(player, "Kingdom");
            }
        }
Beispiel #8
0
        public override void Assign(Room room)
        {
            AssignGeneralsForPlayers(room, out Dictionary <Player, List <string> > options);

            List <Interactivity> receivers = new List <Interactivity>();

            foreach (Player player in options.Keys)
            {
                player.SetTag("generals", JsonUntity.Object2Json(options[player]));
                List <string> args = new List <string>
                {
                    player.Name,
                    string.Empty,
                    JsonUntity.Object2Json(options[player]),
                    false.ToString(),
                    true.ToString(),
                    true.ToString()
                };
                Interactivity client = room.GetInteractivity(player);
                if (client != null && !receivers.Contains(client))
                {
                    client.CommandArgs = args;
                    receivers.Add(client);
                }
            }

            List <Player> players   = room.Players;
            Countdown     countdown = new Countdown
            {
                Max  = room.Setting.GetCommandTimeout(CommandType.S_COMMAND_CHOOSE_GENERAL, ProcessInstanceType.S_CLIENT_INSTANCE),
                Type = Countdown.CountdownType.S_COUNTDOWN_USE_SPECIFIED
            };

            room.NotifyMoveFocus(players, countdown);
            room.DoBroadcastRequest(receivers, CommandType.S_COMMAND_CHOOSE_GENERAL);
            room.DoBroadcastNotify(CommandType.S_COMMAND_UNKNOWN, new List <string> {
                false.ToString()
            });

            foreach (Player player in options.Keys)
            {
                player.RemoveTag("generals");
                if (!string.IsNullOrEmpty(player.General1))
                {
                    continue;
                }
                bool          success = true;
                Interactivity client  = room.GetInteractivity(player);
                List <string> reply   = client?.ClientReply;
                if (client == null || !client.IsClientResponseReady || reply == null || reply.Count == 0 || string.IsNullOrEmpty(reply[0]))
                {
                    success = false;
                }
                else
                {
                    string   generalName = reply[0];
                    string[] generals    = generalName.Split('+');
                    if (generals.Length != 2 || (!options[player].Contains(generals[0]) && room.GetClient(player).UserRight < 3) ||
                        (!options[player].Contains(generals[1]) && room.GetClient(player).UserRight < 3) ||
                        !SetPlayerGeneral(room, player, generals[0], true) ||
                        !SetPlayerGeneral(room, player, generals[1], false))
                    {
                        success = false;
                    }
                }
                if (!success)
                {
                    List <string> default_generals = GeneralSelctor.GeInstance().SelectGenerals(room, options[player]);
                    SetPlayerGeneral(room, player, default_generals[0], true);
                    SetPlayerGeneral(room, player, default_generals[1], false);
                }
            }

            foreach (Player player in players)
            {
                List <string> names = new List <string>();
                if (!string.IsNullOrEmpty(player.General1))
                {
                    string name = player.General1;
                    player.Kingdom = General.GetKingdom(Engine.GetGeneral(player.General1, room.Setting.GameMode).Kingdom[0]);
                    string role = Engine.GetMappedRole(player.Kingdom);
                    if (string.IsNullOrEmpty(role))
                    {
                        role = General.GetKingdom(Engine.GetGeneral(player.General1, room.Setting.GameMode).Kingdom[0]);
                    }
                    names.Add(name);
                    player.Role     = role;
                    player.General1 = "anjiang";
                    foreach (Client p in room.Clients)
                    {
                        if (p != room.GetClient(player))
                        {
                            room.NotifyProperty(p, player, "Kingdom", "god");
                        }
                    }
                    room.BroadcastProperty(player, "General1");
                    room.NotifyProperty(room.GetClient(player), player, "ActualGeneral1");
                    room.NotifyProperty(room.GetClient(player), player, "Kingdom");
                }

                if (!string.IsNullOrEmpty(player.General2))
                {
                    string name = player.General2;
                    names.Add(name);
                    player.General2 = "anjiang";
                    room.BroadcastProperty(player, "General2");
                    room.NotifyProperty(room.GetClient(player), player, "ActualGeneral2");
                }
                room.SetTag(player.Name, names);

                room.HandleUsedGeneral(names[0]);
                room.HandleUsedGeneral(names[1]);

                if (reserved.TryGetValue(player, out List <string> p_reserved) && (p_reserved.Contains(names[0]) || p_reserved.Contains(names[1])))
                {
                    LogMessage reserved_log = new LogMessage();
                    reserved_log.Type = "#reserved_pick";
                    reserved_log.From = player.Name;
                    room.SendLog(reserved_log);
                }

                if (!options[player].Contains(names[0]) || !options[player].Contains(names[1]))
                {
                    LogMessage log = new LogMessage();
                    log.Type = "#cheat_pick";
                    log.From = player.Name;
                    room.SendLog(log);
                }
            }

            //君主转换
            if (room.Setting.LordConvert)
            {
                room.AskForLordConvert();
            }

            foreach (Player player in players)
            {
                General general1 = Engine.GetGeneral(player.ActualGeneral1, room.Setting.GameMode);
                General general2 = Engine.GetGeneral(player.ActualGeneral2, room.Setting.GameMode);

                if (general1.CompanionWith(player.ActualGeneral2, Name))
                {
                    player.AddMark("CompanionEffect");
                }

                int max_hp = general1.GetMaxHpHead() + general2.GetMaxHpDeputy();
                player.SetMark("HalfMaxHpLeft", max_hp % 2);

                player.MaxHp = max_hp / 2;
                player.Hp    = player.MaxHp;

                room.BroadcastProperty(player, "MaxHp");
                room.BroadcastProperty(player, "Hp");
            }
        }
Beispiel #9
0
        public override void Assign(Room room)
        {
            AssignGeneralsForPlayers(room, out Dictionary <Player, List <string> > options);

            List <Interactivity> receivers = new List <Interactivity>();

            foreach (Player player in options.Keys)
            {
                player.SetTag("generals", JsonUntity.Object2Json(options[player]));
                List <string> args = new List <string>
                {
                    player.Name,                                    //操作的玩家名
                    string.Empty,                                   //原因
                    JsonUntity.Object2Json(options[player]),        //备选武将
                    false.ToString(),                               //是否单将
                    true.ToString(),                                //是否可以武将转换SP
                    false.ToString()                                //双将时是否匹配相同国籍
                };
                Interactivity client = room.GetInteractivity(player);
                if (client != null && !receivers.Contains(client))
                {
                    client.CommandArgs = args;
                    receivers.Add(client);
                }
            }

            List <Player> players   = room.Players;
            Countdown     countdown = new Countdown
            {
                Max  = room.Setting.GetCommandTimeout(CommandType.S_COMMAND_CHOOSE_GENERAL, ProcessInstanceType.S_CLIENT_INSTANCE),
                Type = Countdown.CountdownType.S_COUNTDOWN_USE_SPECIFIED
            };

            room.NotifyMoveFocus(players, countdown);
            room.DoBroadcastRequest(receivers, CommandType.S_COMMAND_CHOOSE_GENERAL);
            room.DoBroadcastNotify(CommandType.S_COMMAND_UNKNOWN, new List <string> {
                false.ToString()
            });

            foreach (Player player in options.Keys)
            {
                player.RemoveTag("generals");
                if (!string.IsNullOrEmpty(player.General1))
                {
                    continue;
                }
                bool          success = true;
                Interactivity client  = room.GetInteractivity(player);
                List <string> reply   = client?.ClientReply;
                if (client == null || !client.IsClientResponseReady || reply == null || reply.Count == 0 || string.IsNullOrEmpty(reply[0]))
                {
                    success = false;
                }
                else
                {
                    string   generalName = reply[0];
                    string[] generals    = generalName.Split('+');
                    if (generals.Length != 2 || (!options[player].Contains(generals[0]) && room.GetClient(player).UserRight < 3) ||
                        (!options[player].Contains(generals[1]) && room.GetClient(player).UserRight < 3) ||
                        !SetPlayerGeneral(room, player, generals[0], true) ||
                        !SetPlayerGeneral(room, player, generals[1], false))
                    {
                        success = false;
                    }
                }
                if (!success)
                {
                    SetPlayerGeneral(room, player, options[player][0], true);
                    SetPlayerGeneral(room, player, options[player][1], false);
                }
            }

            foreach (Player player in players)
            {
                List <string> names = new List <string>();
                if (!string.IsNullOrEmpty(player.General1))
                {
                    string name = player.General1;
                    names.Add(name);
                    player.General1 = "anjiang";
                    room.BroadcastProperty(player, "General1");
                    room.NotifyProperty(room.GetClient(player), player, "ActualGeneral1");

                    foreach (Client p in room.Clients)
                    {
                        if (p != room.GetClient(player))
                        {
                            room.NotifyProperty(p, player, "Kingdom", "god");
                        }
                    }
                }

                if (!string.IsNullOrEmpty(player.General2))
                {
                    string name = player.General2;
                    names.Add(name);
                    player.General2 = "anjiang";
                    room.BroadcastProperty(player, "General2");
                    room.NotifyProperty(room.GetClient(player), player, "ActualGeneral2");
                }
                room.SetTag(player.Name, names);

                room.HandleUsedGeneral(names[0]);
                room.HandleUsedGeneral(names[1]);

                if (reserved.TryGetValue(player, out List <string> p_reserved) && (p_reserved.Contains(names[0]) || p_reserved.Contains(names[1])))
                {
                    LogMessage reserved_log = new LogMessage();
                    reserved_log.Type = "#reserved_pick";
                    reserved_log.From = player.Name;
                    room.SendLog(reserved_log);
                }

                if (!options[player].Contains(names[0]) || !options[player].Contains(names[1]))
                {
                    LogMessage log = new LogMessage();
                    log.Type = "#cheat_pick";
                    log.From = player.Name;
                    room.SendLog(log);
                }
            }

            //选择国籍
            receivers.Clear();
            players.Clear();
            List <string> prompts = new List <string> {
                "@choose-kingdom"
            };
            Dictionary <Player, List <string> > kingdoms = new Dictionary <Player, List <string> >();

            foreach (Player player in room.Players)
            {
                List <string> choices = new List <string> {
                    "careerist"
                };
                General g1 = Engine.GetGeneral(player.ActualGeneral1, Name);
                General g2 = Engine.GetGeneral(player.ActualGeneral2, Name);
                foreach (General.KingdomENUM kingdom in g1.Kingdom)
                {
                    if (!choices.Contains(General.GetKingdom(kingdom)))
                    {
                        choices.Add(General.GetKingdom(kingdom));
                    }
                }
                foreach (General.KingdomENUM kingdom in g2.Kingdom)
                {
                    if (!choices.Contains(General.GetKingdom(kingdom)))
                    {
                        choices.Add(General.GetKingdom(kingdom));
                    }
                }
                kingdoms.Add(player, choices);
                List <string> args = new List <string>
                {
                    player.Name,
                    "Kingdom",
                    string.Join("+", choices),
                    JsonUntity.Object2Json(prompts)
                };
                Interactivity client = room.GetInteractivity(player);
                if (client != null && !receivers.Contains(client))
                {
                    client.CommandArgs = args;
                    receivers.Add(client);
                }
                players.Add(player);
            }

            countdown = new Countdown
            {
                Max  = room.Setting.GetCommandTimeout(CommandType.S_COMMAND_MULTIPLE_CHOICE, ProcessInstanceType.S_CLIENT_INSTANCE),
                Type = Countdown.CountdownType.S_COUNTDOWN_USE_SPECIFIED
            };
            room.NotifyMoveFocus(players, countdown);
            room.DoBroadcastRequest(receivers, CommandType.S_COMMAND_MULTIPLE_CHOICE);
            room.DoBroadcastNotify(CommandType.S_COMMAND_UNKNOWN, new List <string> {
                false.ToString()
            });

            foreach (Player player in players)
            {
                string        answer        = string.Empty;
                Interactivity interactivity = room.GetInteractivity(player);
                if (interactivity != null)
                {
                    List <string> clientReply = interactivity.ClientReply;
                    if (clientReply != null && clientReply.Count > 0)
                    {
                        answer = clientReply[0];
                    }
                }

                List <string> choices = kingdoms[player];
                if (string.IsNullOrEmpty(answer) || !choices.Contains(answer))
                {
                    Shuffle.shuffle(ref choices);
                    answer = choices[0];
                }

                if (answer != "careerist")
                {
                    player.Kingdom = player.Role = answer;
                    room.NotifyProperty(room.GetClient(player), player, "Kingdom");
                }
                else
                {
                    player.Kingdom = "god";
                    player.Role    = answer;
                    room.NotifyProperty(room.GetClient(player), player, "Role");
                }
            }

            //君主转换
            if (room.Setting.LordConvert)
            {
                room.AskForLordConvert();
            }

            foreach (Player player in players)
            {
                General general1 = Engine.GetGeneral(player.ActualGeneral1, room.Setting.GameMode);
                General general2 = Engine.GetGeneral(player.ActualGeneral2, room.Setting.GameMode);

                if (general1.CompanionWith(player.ActualGeneral2, Name))
                {
                    player.AddMark("CompanionEffect");
                }

                int max_hp = general1.GetMaxHpHead() + general2.GetMaxHpDeputy();
                player.SetMark("HalfMaxHpLeft", max_hp % 2);

                player.MaxHp = max_hp / 2;
                player.Hp    = player.MaxHp;

                room.BroadcastProperty(player, "MaxHp");
                room.BroadcastProperty(player, "Hp");
            }
        }
Beispiel #10
0
        public override void Assign(Room room)
        {
            System.Threading.Thread.Sleep(1000);

            List <Player> players = new List <Player>();

            if (room.Players.Count == 8)
            {
                List <string> soldiers = new List <string> {
                    "longxiangjun", "hubenjun", "baoluejun", "fengyaojun", "feixiongjun", "tanlangjun"
                };
                Shuffle.shuffle(ref soldiers);

                room.Players[1].General1 = room.Players[1].ActualGeneral1 = soldiers[0];
                room.Players[2].General1 = room.Players[2].ActualGeneral1 = "huaxiong_al";
                room.Players[3].General1 = room.Players[3].ActualGeneral1 = soldiers[1];
                room.Players[5].General1 = room.Players[5].ActualGeneral1 = soldiers[2];
                room.Players[6].General1 = room.Players[6].ActualGeneral1 = "sunjian_jx";
                room.Players[7].General1 = room.Players[7].ActualGeneral1 = soldiers[3];

                players.Add(room.Players[0]);
                players.Add(room.Players[4]);
                foreach (Player lord in room.Players)
                {
                    if (lord.Camp == Game3v3Camp.S_CAMP_WARM || lord.General1 == "sunjian_jx")
                    {
                        General lord_gen = Engine.GetGeneral(lord.General1, room.Setting.GameMode);
                        lord.PlayerGender   = lord_gen.GeneralGender;
                        lord.Kingdom        = General.GetKingdom(lord_gen.Kingdom[0]);
                        lord.General1Showed = true;
                        room.BroadcastProperty(lord, "General1");
                        room.BroadcastProperty(lord, "PlayerGender");
                        room.BroadcastProperty(lord, "Kingdom");
                        room.BroadcastProperty(lord, "General1Showed");
                        foreach (string skill in Engine.GetGeneralSkills(lord.General1, Name, true))
                        {
                            room.AddPlayerSkill(lord, skill);
                            Skill s = Engine.GetSkill(skill);
                            if (s != null && s.SkillFrequency == Frequency.Limited && !string.IsNullOrEmpty(s.LimitMark))
                            {
                                room.SetPlayerMark(lord, s.LimitMark, 1);
                            }
                        }

                        room.SendPlayerSkillsToOthers(lord, true);

                        //技能预亮
                        lord.SetSkillsPreshowed("hd");
                        room.NotifyPlayerPreshow(lord);
                        room.HandleUsedGeneral(lord.General1);
                    }
                }
            }
            else
            {
                //随机关卡
                Random rand  = new Random();
                int    stage = rand.Next(0, 6);
                //AI将领
                switch (stage)
                {
                case 0:
                    room.Players[3].General1 = room.Players[3].ActualGeneral1 = "zhangji_al";
                    room.Players[2].General1 = room.Players[2].ActualGeneral1 = room.Players[4].General1 = room.Players[4].ActualGeneral1 = "longxiangjun";
                    break;

                case 1:
                    room.Players[3].General1 = room.Players[3].ActualGeneral1 = "fanchou_al";
                    room.Players[2].General1 = room.Players[2].ActualGeneral1 = room.Players[4].General1 = room.Players[4].ActualGeneral1 = "hubenjun";
                    break;

                case 2:
                    room.Players[3].General1 = room.Players[3].ActualGeneral1 = "dongxie_al";
                    room.Players[2].General1 = room.Players[2].ActualGeneral1 = room.Players[4].General1 = room.Players[4].ActualGeneral1 = "fengyaojun";
                    break;

                case 3:
                    room.Players[3].General1 = room.Players[3].ActualGeneral1 = "dongyue_al";
                    room.Players[2].General1 = room.Players[2].ActualGeneral1 = room.Players[4].General1 = room.Players[4].ActualGeneral1 = "baoluejun";
                    break;

                case 4:
                    room.Players[2].General1 = room.Players[2].ActualGeneral1 = "tanlangjun";
                    room.Players[3].General1 = room.Players[3].ActualGeneral1 = "lijue_al";
                    room.Players[4].General1 = room.Players[4].ActualGeneral1 = "feixiongjun";
                    break;

                case 5:
                    room.Players[2].General1 = room.Players[2].ActualGeneral1 = "tanlangjun";
                    room.Players[3].General1 = room.Players[3].ActualGeneral1 = "guosi_al";
                    room.Players[4].General1 = room.Players[4].ActualGeneral1 = "feixiongjun";
                    break;
                }

                players.Add(room.Players[0]);
                players.Add(room.Players[1]);
                foreach (Player lord in room.Players)
                {
                    if (lord.Camp == Game3v3Camp.S_CAMP_WARM)
                    {
                        General lord_gen = Engine.GetGeneral(lord.General1, room.Setting.GameMode);
                        lord.PlayerGender   = lord_gen.GeneralGender;
                        lord.Kingdom        = General.GetKingdom(lord_gen.Kingdom[0]);
                        lord.General1Showed = true;
                        room.BroadcastProperty(lord, "General1");
                        room.BroadcastProperty(lord, "PlayerGender");
                        room.BroadcastProperty(lord, "Kingdom");
                        room.BroadcastProperty(lord, "General1Showed");
                        foreach (string skill in Engine.GetGeneralSkills(lord.General1, Name, true))
                        {
                            room.AddPlayerSkill(lord, skill);
                            Skill s = Engine.GetSkill(skill);
                            if (s != null && s.SkillFrequency == Frequency.Limited && !string.IsNullOrEmpty(s.LimitMark))
                            {
                                room.SetPlayerMark(lord, s.LimitMark, 1);
                            }
                        }

                        room.SendPlayerSkillsToOthers(lord, true);

                        //技能预亮
                        lord.SetSkillsPreshowed("hd");
                        room.NotifyPlayerPreshow(lord);
                        room.HandleUsedGeneral(lord.General1);
                    }
                }
            }
            System.Threading.Thread.Sleep(700);

            //为其余玩家分配武将
            AssignGeneralsForPlayers(room, out Dictionary <Player, List <string> > options);
            //选将
            List <Interactivity> receivers             = new List <Interactivity>();
            Dictionary <string, List <string> > choose = new Dictionary <string, List <string> >();

            foreach (Player player in options.Keys)
            {
                choose[player.Name] = options[player];
            }

            foreach (Player player in options.Keys)
            {
                player.SetTag("generals", JsonUntity.Object2Json(options[player]));
                List <string> args = new List <string>
                {
                    player.Name,
                    JsonUntity.Object2Json(choose),
                };
                Interactivity client = room.GetInteractivity(player);
                if (client != null)
                {
                    client.CommandArgs = args;
                    receivers.Add(client);
                }
                players.Add(player);
            }

            Countdown countdown = new Countdown
            {
                Max  = room.Setting.GetCommandTimeout(CommandType.S_COMMAND_GENERAL_PICK, ProcessInstanceType.S_CLIENT_INSTANCE),
                Type = Countdown.CountdownType.S_COUNTDOWN_USE_SPECIFIED
            };

            room.NotifyMoveFocus(players, countdown);
            room.DoBroadcastRequest(receivers, CommandType.S_COMMAND_GENERAL_PICK);
            room.DoBroadcastNotify(CommandType.S_COMMAND_UNKNOWN, new List <string> {
                false.ToString()
            });

            //给AI和超时的玩家自动选择武将
            foreach (Player player in options.Keys)
            {
                player.RemoveTag("generals");
                if (string.IsNullOrEmpty(player.General1))
                {
                    string        generalName = string.Empty;
                    Interactivity client      = room.GetInteractivity(player);
                    List <string> reply       = client?.ClientReply;
                    bool          success     = true;
                    if (reply == null || reply.Count == 0 || string.IsNullOrEmpty(reply[0]))
                    {
                        success = false;
                    }
                    else
                    {
                        generalName = reply[0];
                    }

                    if (!success)
                    {
                        if (client == null)
                        {
                            continue;
                        }
                        else
                        {
                            generalName = options[player][0];
                        }
                    }
                    else if (!string.IsNullOrEmpty(generalName) && !options[player].Contains(generalName) && room.GetClient(player).UserRight < 3)
                    {
                        generalName = options[player][0];
                    }

                    player.General1       = generalName;
                    player.ActualGeneral1 = generalName;
                    player.Kingdom        = General.GetKingdom(Engine.GetGeneral(generalName, room.Setting.GameMode).Kingdom[0]);
                    player.General1Showed = true;
                }

                room.BroadcastProperty(player, "General1");
                room.NotifyProperty(room.GetClient(player), player, "ActualGeneral1");
                room.BroadcastProperty(player, "Kingdom");
                room.BroadcastProperty(player, "General1Showed");
                player.PlayerGender = Engine.GetGeneral(player.General1, room.Setting.GameMode).GeneralGender;
                room.BroadcastProperty(player, "PlayerGender");

                player.SetSkillsPreshowed("hd");
                room.NotifyPlayerPreshow(player);
                List <string> names = new List <string> {
                    player.General1
                };
                room.SetTag(player.Name, names);
                room.HandleUsedGeneral(player.General1);
            }

            foreach (Player player in options.Keys)
            {
                if (string.IsNullOrEmpty(player.General1))
                {
                    Player human = null;
                    foreach (Player p2 in options.Keys)
                    {
                        if (p2 != player)
                        {
                            human = p2;
                            break;
                        }
                    }
                    string generalName = room.AskForGeneral(human, options[player], null, true, Name, null, true);

                    player.General1       = generalName;
                    player.ActualGeneral1 = generalName;
                    player.Kingdom        = General.GetKingdom(Engine.GetGeneral(generalName, room.Setting.GameMode).Kingdom[0]);
                    player.General1Showed = true;

                    room.BroadcastProperty(player, "General1");
                    room.NotifyProperty(room.GetClient(player), player, "ActualGeneral1");
                    room.BroadcastProperty(player, "Kingdom");
                    room.BroadcastProperty(player, "General1Showed");
                    player.PlayerGender = Engine.GetGeneral(player.General1, room.Setting.GameMode).GeneralGender;
                    room.BroadcastProperty(player, "PlayerGender");

                    player.SetSkillsPreshowed("hd");
                    room.NotifyPlayerPreshow(player);
                    List <string> names = new List <string> {
                        player.General1
                    };
                    room.SetTag(player.Name, names);
                    room.HandleUsedGeneral(player.General1);
                }
            }
        }