//public Player Player
 //{
 //    get { return player; }
 //    set { player = value; }
 //}
 public RemoteGameController(Player player, ClientSide clientSide, UDPClientServerCommons.Packets.GameInfoPacket gameInfo)
 {
     gameStatus = GameStatus.WaitingForStart;
     clientNetworkLayer = clientSide;
     this.player = player;
     this.gameInfo = gameInfo;
 }
 public override void Help(Player p)
 {
     p.SendMessage("/cd - Command shortcut.");
     p.SendMessage("/countdown join - join the game");
     p.SendMessage("/countdown leave - leave the game");
     p.SendMessage("/countdown goto - goto the countdown map");
     p.SendMessage("/countdown players - view players currently playing");
     {
         if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 1))
         {
             p.SendMessage("/countdown rules <send> <all/map/player> - the rules of countdown. with send: all to send to all, map to send to map and have a players name to send to a player");
         }
         else
         {
             p.SendMessage("/countdown rules - view the rules of countdown");
         }
         if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this, 2))
         {
             p.SendMessage("/countdown download - download the countdown map");
             p.SendMessage("/countdown enable - enable the game");
             p.SendMessage("/countdown disable - disable the game");
             p.SendMessage("/countdown cancel - cancels a game");
             p.SendMessage("/countdown start [speed] [mode] - start the game, speeds are 'slow', 'normal', 'fast', 'extreme' and 'ultimate', modes are 'normal' and 'freeze'");
             p.SendMessage("/countdown reset [all/map] - reset the whole game (all) or only the map (map)");
             p.SendMessage("/countdown tutorial - a tutorial on how to setup countdown");
         }
     }
 }
 public MultiplayerChatRoom(String Name, String IP)
 {
     InitializeComponent();
     players.Add(player = new Player(Name));
     dataGrid.ItemsSource = players;
     StartClient(IP);
 }
Example #4
0
        public override void Use(Player p, params string[] args)
        {
            int port = 25565;

            if (args.Length == 0)
            {
                if (!p.IsConsole) p.SendMessage("Checking port....");
                else Logger.Log("Checking Port...");
                checkport(25565, p);
            }
            else if (args.Length == 1)
            {
                try
                {
                    port = Convert.ToInt32(args[0]);
                    if (!p.IsConsole) p.SendMessage("Checking port....");
                    else Logger.Log("Checking Port...");
                    checkport(port, p);
                }
                catch (Exception)
                {
                    if (!p.IsConsole) p.SendMessage("port must be a number");
                    else Logger.Log("Port must be a number");
                }
            }
        }
Example #5
0
        public override void Use(Player p, string message)
        {
            if (p == null) { Player.SendMessage(p, "This command can only be used in-game!"); return; }
            if (!Directory.Exists("extra/copy"))
                Directory.CreateDirectory("extra/copy");

            if (!File.Exists("extra/copy/nyancat.copy"))
            {
                Player.SendMessage(p, "Nyan Cat copy doesn't exist. Downloading...");
                try
                {
                    using (WebClient WEB = new WebClient())
                        WEB.DownloadFile("http://mcforge.net/uploads/copy/nyancat.copy", "extra/copy/nyancat.copy");
                    }
                    catch
                    {
                        Player.SendMessage(p, "Sorry, downloading failed. Please try again later.");
                        return;
                    }
                }
                Command.all.Find("retrieve").Use(p, "nyancat");
                Command.all.Find("paste").Use(p, "");
                ushort[] loc = p.getLoc(false);
                Command.all.Find("click").Use(p, loc[0] + " " + loc[1] + " " + loc[2]);
        }
Example #6
0
        public override void Use(Player p, string message)
        {
            if (!Directory.Exists("extra/passwords"))
                Directory.CreateDirectory("extra/passwords");
            if ( p.group.Permission < Server.verifyadminsrank ) {
                Player.SendMessage(p, "You do not have the &crequired rank " + Server.DefaultColor + "to use this command!");
                return;
            }
            if ( !Server.verifyadmins ) {
                Player.SendMessage(p, "Verification of admins is &cdisabled!");
                return;
            }
            if ( p.adminpen ) {
                if ( File.Exists("extra/passwords/" + p.name + ".dat") ) {
                    Player.SendMessage(p, "&cYou already have a password set. " + Server.DefaultColor + "You &ccannot change " + Server.DefaultColor + "it unless &cyou verify it with &a/pass [Password]. " + Server.DefaultColor + "If you have &cforgotten " + Server.DefaultColor + "your password, contact &c" + Server.server_owner + Server.DefaultColor + " and they can &creset it!");
                    return;
                }
            }
            if ( String.IsNullOrEmpty(message.Trim()) ) {
                Help(p);
                return;

            }
            int number = message.Split(' ').Length;
            if ( number > 1 ) {
                Player.SendMessage(p, "Your password must be one word!");
                return;
            }
            PasswordHasher.StoreHash(p.name, message);
            Player.SendMessage(p, "Your password has &asuccessfully &abeen set to:");
            Player.SendMessage(p, "&c" + message);
        }
Example #7
0
        public void addGoalieFromPlayer(Player myPlayer)
        {
            Goalie myGoalie = null;
            
            //ensure the current player is removed from the list
            for (int i = 0; i < players.Count; i++)
            {
                if (players[i].Equals(myPlayer))
                {
                    //if there is a player object matching the given player

                    //if that player is a goalie
                    if (players[i].GetType().ToString().Equals("icehockeyWA.Models.Goalie"))
                    {
                        //set the current goalie to that player
                        myGoalie = (Goalie)players[i];
                    }
                    else
                    {
                        players.RemoveAt(i);
                        //create a new goalie object in the list
                        myGoalie = new Goalie(myPlayer.playerID, myPlayer.name, myPlayer.number);
                        players.Add(myGoalie);
                    }
                }
            }

            currentGoalie = myGoalie;
        }
Example #8
0
        private void DoAttack(Player attacker, Player attacked)
        {
            List<CardModel> revealed = attacked.DrawCards(2);
            if (revealed.Count > 0)
            {
                string cards = Log.FormatSortedCards(revealed);

                string target = attacked == attacker ? "You" : attacked.Name;
                int choice = attacker.Chooser.ChooseOneEffect(attacker == attacked ? EffectChoiceType.DiscardOrPutOnDeckToDraw: EffectChoiceType.ForceDiscardOrPutOnDeck, revealed, target + " revealed " + cards, choices, choices);
                if (choice == 0)
                {
                    IEnumerable<CardModel> order = attacked.Chooser.ChooseOrder(CardOrderType.OrderOnDeck, "Put " + cards + " back in any order", revealed);
                    foreach (CardModel c in order)
                    {
                        attacked.Deck.PlaceOnTop(c);
                    }
                }
                else
                {
                    foreach (CardModel c in revealed)
                    {
                        attacked.DiscardCard(c);
                    }
                }
            }
        }
Example #9
0
        private void DoAttack(Player attacker, Player attacked)
        {
            List<CardModel> cards = attacked.DrawCards(2);

            bool hadTreasure = cards.Any(c => c.Is(CardType.Treasure));
            IEnumerable<CardModel> gainable = cards.Where(c => c is Silver || c is Gold);

            if (gainable.Any())
            {
                CardModel treasure = attacker.Chooser.ChooseOneCard(CardChoiceType.TrashForNobleBrigand, "Trash a treasure", ChoiceSource.None, gainable);
                if (treasure != null)
                {
                    attacked.Trash(treasure);
                    attacker.GainCard(treasure, null);
                    cards.Remove(treasure);
                }
            }

            foreach (CardModel other in cards)
            {
                attacked.DiscardCard(other);
            }

            if (!hadTreasure)
            {
                attacked.GainCard(typeof(Copper));
            }
        }
Example #10
0
        public static void AddPlayerFlagAndName(ScrollItemWidget template, Player player)
        {
            var flag = template.Get<ImageWidget>("FLAG");
            flag.GetImageCollection = () => "flags";
            if (player.World.RenderPlayer != null && player.World.RenderPlayer.Stances[player] != Stance.Ally)
                flag.GetImageName = () => player.DisplayFaction.InternalName;
            else
                flag.GetImageName = () => player.Faction.InternalName;

            var client = player.World.LobbyInfo.ClientWithIndex(player.ClientIndex);
            var playerName = template.Get<LabelWidget>("PLAYER");
            var playerNameFont = Game.Renderer.Fonts[playerName.Font];
            var suffixLength = new CachedTransform<string, int>(s => playerNameFont.Measure(s).X);
            var name = new CachedTransform<Pair<string, int>, string>(c =>
                WidgetUtils.TruncateText(c.First, playerName.Bounds.Width - c.Second, playerNameFont));

            playerName.GetText = () =>
            {
                var suffix = player.WinState == WinState.Undefined ? "" : " (" + player.WinState + ")";
                if (client != null && client.State == Session.ClientState.Disconnected)
                    suffix = " (Gone)";

                var sl = suffixLength.Update(suffix);
                return name.Update(Pair.New(player.PlayerName, sl)) + suffix;
            };

            playerName.GetColor = () => player.Color.RGB;
        }
 public void Start(Player player, TcpClient inClientSocket)
 {
     IsRunning = true;
     Player = player;
     clientSocket = inClientSocket;
     Thread ctThread = new Thread(Listen);
     ctThread.Start();
 }
Example #12
0
        public override void Use(Player p, string message)
        {
            if ( p.group.Permission < Server.verifyadminsrank ) {
                Player.SendMessage(p, "You do not have the &crequired rank to use this command!");
                return;
            }

            if ( !Server.verifyadmins ) {
                Player.SendMessage(p, "Verification of admins is &cdisabled!");
                return;
            }

            if ( !p.adminpen ) {
                Player.SendMessage(p, "You have &calready verified.");
                return;
            }

            if ( p.passtries >= 3 ) {
                p.Kick("Did you really think you could keep on guessing?");
                return;
            }

            if ( String.IsNullOrEmpty(message.Trim()) ) {
                Help(p);
                return;
            }

            int number = message.Split(' ').Length;

            if ( number > 1 ) {
                Player.SendMessage(p, "Your password must be &cone " + Server.DefaultColor + "word!");
                return;
            }

            if ( !Directory.Exists("extra/passwords") ) {
                Player.SendMessage(p, "You have not &cset a password, " + Server.DefaultColor + "use &a/setpass [Password] &cto set one!");
                return;
            }

            DirectoryInfo di = new DirectoryInfo("extra/passwords/");
            FileInfo[] fi = di.GetFiles("*.dat");
            if ( !File.Exists("extra/passwords/" + p.name + ".dat") ) {
                Player.SendMessage(p, "You have not &cset a password, " + Server.DefaultColor + "use &a/setpass [Password] &cto set one!");
                return;
            }

            if ( PasswordHasher.MatchesPass(p.name, message) ) {
                Player.SendMessage(p, "Thank you, " + p.color + p.name + Server.DefaultColor + "! You have now &averified " + Server.DefaultColor + "and have &aaccess to admin commands and features!");
                if ( p.adminpen ) {
                    p.adminpen = false;
                }
                return;
            }

            p.passtries++;
            Player.SendMessage(p, "&cWrong Password. " + Server.DefaultColor + "Remember your password is &ccase sensitive!");
            Player.SendMessage(p, "Forgot your password? " + Server.DefaultColor + "Contact the owner so they can reset it!");
        }
 public void Blockchange1(Player p, ushort x, ushort y, ushort z, ushort type)
 {
     p.ClearBlockchange();
     ushort b = p.level.GetTile(x, y, z);
     p.SendBlockchange(x, y, z, b);
     CatchPos bp = (CatchPos)p.blockchangeObject;
     bp.x = x; bp.y = y; bp.z = z; p.blockchangeObject = bp;
     p.Blockchange += new Player.BlockchangeEventHandler(Blockchange2);
 }
Example #14
0
 public override void OnGain(GameModel gameModel, Player player)
 {
     foreach (Player otherPlayer in gameModel.Players)
     {
         if (otherPlayer != player)
         {
             this.DoAttack(player, otherPlayer);
         }
     }
 }
Example #15
0
 public override void Help(Player p)
 {
     Player.SendMessage(p, "%f/report [Player] [Reason] " + Server.DefaultColor + "- Reports the specified player for the reason");
     if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this)) {
         Player.SendMessage(p, "%f/report list " + Server.DefaultColor + "- Checks the reported list!");
         Player.SendMessage(p, "%f/report check [Player] " + Server.DefaultColor + "- View the report on the specified player");
         Player.SendMessage(p, "%f/report delete [Player] " + Server.DefaultColor + "- Delete the report on the specified player");
         Player.SendMessage(p, "%f/report clear " + Server.DefaultColor + "- %c!!!Clears all reports!!!");
     }
 }
Example #16
0
 public override void OnGain(GameModel gameModel, Player player)
 {
     foreach (Player otherPlayer in gameModel.Players)
     {
         if (player != otherPlayer)
         {
             otherPlayer.GainCard(typeof(Curse));
         }
     }
 }
Example #17
0
 public override void Help(Player p)
 {
     Player.SendMessage(p, "/report [Player] [Reason] - Reports the specified player for the reason/");
     if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this))
     {
         Player.SendMessage(p, "/report check - Checks the reported list!");
         Player.SendMessage(p, "/report view [Player] - View the report on the specified player");
         Player.SendMessage(p, "/report delete [Player] - Delete the report on the specified player");
     }
 }
 public override void ChangePlayerTeam(Player player, GameTeam newTeam)
 {
     World.Instance.ChangeTeam(player, newTeam);
     if (player == this.player)
     {
         if (newTeam == GameTeam.Assassins)
             clientNetworkLayer.ChangeTeam(clientNetworkLayer.CurrentGameInfo.TeamScoreList[0].TeamId);
         else
             clientNetworkLayer.ChangeTeam(clientNetworkLayer.CurrentGameInfo.TeamScoreList[1].TeamId);
     }
 }
        public override void AddPlayer(Player player)
        {
            World.Instance.AddPlayer(player);
            if (player == this.player)
            {
                ushort id = (Player.CharacterClass.GameTeam == GameTeam.Assassins) ? gameInfo.TeamScoreList[0].TeamId : gameInfo.TeamScoreList[1].TeamId;
                bool ret = clientNetworkLayer.JoinGame(gameInfo.ServerAddress, player.Name, gameInfo.GameId, id);

                //ChangePlayerTeam(player, player.CharacterClass.GameTeam);
            }
        }
Example #20
0
 public void Blockchange1(Player p, ushort x, ushort y,ushort z,byte Type)
 {
     //get the pos of first block
     p.ClearBlockchange();
     byte t = p.level.GetTile(x, y, z);
     p.SendBlockchange(x, y, z, t);
     //undone change
     blox[0].x = x;
     blox[0].y = y;
     blox[0].z = z;
     p.Blockchange += new Player.BlockchangeEventHandler(Blockchange2);
 }
Example #21
0
        public override void OnGain(GameModel gameModel, Player player)
        {
            IEnumerable<CardModel> discardedActions = player.Discard.Where(card => card.Is(CardType.Action));
            IEnumerable<CardModel> choices = player.Chooser.ChooseSeveralCards(CardChoiceType.Inn, "Choose actions to shuffle into your deck", ChoiceSource.None, 0, discardedActions.Count(), discardedActions);
            foreach(CardModel choice in choices.ToArray())
            {
                player.RemoveFromDiscard(choice);
                player.Deck.PlaceOnTop(choice);
            }

            player.Deck.Shuffle();
        }
Example #22
0
 public override void Help(Player p)
 {
     if (p.IsConsole)
     {
         Logger.Log("/checkport or /cp");
         Logger.Log("OPTIONAL you can specify another port by doing /cp <port>");
     }
     else
     {
         p.SendMessage("/checkport or /cp");
         p.SendMessage("OPTIONAL you can specify another port by doing /cp <port>");
     }
 }
Example #23
0
 void OnUserConnectionStateChanged(object sender, ConnectionEventArgs e)
 {
     if (e.State == ConnectionState.Connected) {
         var player = new Player { Name = "plr_" + DateTime.Now.Millisecond.ToString(CultureInfo.InvariantCulture) };
         e.User["player"] = player;
         _service.AddEntity(player);
         Console.WriteLine("'{0}' connected", player.Name);
     } else if (e.State == ConnectionState.Disconnected) {
         var player = (Player)e.User["player"];
         _service.RemoveEntity(player);
         Console.WriteLine("'{0}' disconnected", player.Name);
     }
 }
Example #24
0
        public bool CheckPlayer(Player player)
        {
            byte[] res;

            using (var client = new WebClient())
            {
                var reqparm = new NameValueCollection {{"name", player.Name}, {"data", player.Data}};
                res = client.UploadValues(_url, "POST", reqparm);
            }
            
            var str = Encoding.Default.GetString(res);
            return (str == "1");
        }
Example #25
0
        public override void Use(Player p, params string[] args)
        {
            int port = 25565;

            if (args.Length == 0)
            {
                checkport(25565, p);
            }
            else if (args.Length == 1)
            {
                try { port = Convert.ToInt16(args[0]); checkport(port, p); }
                catch (Exception e) { p.SendMessage("port must be a number"); p.SendMessage(e.Message); p.SendMessage(e.Source); }
            }
        }
Example #26
0
        public Connection(TcpClient client, Player player)
        {
            _Client = client;
            IPString = _Client.Client.RemoteEndPoint.ToString();

            _Running = true;
            _TransmitQueue = new Queue<byte[]>();
            _Buffer = new byte[0];
            _Player = player;

            _Thread = new Thread(ConnectionThread);
            _Thread.Name = "SC-Player " + _Client.GetHashCode();
            _Thread.Start();
        }
Example #27
0
 public override void Use(Player p, string message)
 {
     if (message.ToLower() != "force" && message.ToLower() != "help")
     {
         if (p == null || p.group.Permission > defaultRank) MCForge_.Gui.Program.UpdateCheck(false, p);
         else Player.SendMessage(p, "Ask an " + Group.findPerm(defaultRank).name + "+ to do it!");
     }
     else if (message.ToLower() == "help")
     {
         Help(p);
         return;
     }
     else
     {
         if (p == null || p.group.Permission > defaultRank) MCForge_.Gui.Program.PerformUpdate();
         else Player.SendMessage(p, "Ask an " + Group.findPerm(defaultRank).name + "+ to do it!");
     }
 }
Example #28
0
        public static void AddPlayerFlagAndName(ScrollItemWidget template, Player player)
        {
            var flag = template.Get<ImageWidget>("FLAG");
            flag.GetImageCollection = () => "flags";
            if (player.World.RenderPlayer != null && player.World.RenderPlayer.Stances[player] != Stance.Ally)
                flag.GetImageName = () => player.DisplayFaction.InternalName;
            else
                flag.GetImageName = () => player.Faction.InternalName;

            var playerName = template.Get<LabelWidget>("PLAYER");
            var client = player.World.LobbyInfo.ClientWithIndex(player.ClientIndex);
            playerName.GetText = () =>
            {
                if (client != null && client.State == Network.Session.ClientState.Disconnected)
                    return player.PlayerName + " (Gone)";
                return player.PlayerName + (player.WinState == WinState.Undefined ? "" : " (" + player.WinState + ")");
            };
            playerName.GetColor = () => player.Color.RGB;
        }
 public async void TestChangeChannel()
 {
     var serverConnectionMock = new Mock<IServerConnection>();
     serverConnectionMock.Setup(s => s.Get(It.Is<Uri>(u => u.AbsolutePath.EndsWith("app_channels")), It.IsAny<Action<HttpWebRequest>>())).ReturnsAsync(Resource.ChannelListExample).Verifiable();
     serverConnectionMock.Setup(s => s.Get(It.Is<Uri>(u => u.AbsolutePath.EndsWith("playlist")), It.IsAny<Action<HttpWebRequest>>())).ReturnsAsync(Resource.PlayList).Verifiable();
     var session = new Session(serverConnectionMock.Object);
     var player = new Player(session);
     var channelGroups = await new Discovery(session).GetRecommendedChannels();
     Assert.IsNotNull(channelGroups);
     var newChannels = channelGroups.SelectMany(group => group.Channels).ToArray();
     Assert.IsNotEmpty(newChannels);
     foreach (var newChannel in newChannels)
     {
         await player.ChangeChannel(newChannel);
         serverConnectionMock.Verify();
         Assert.AreEqual(newChannel, player.CurrentChannel);
         Validator.ValidateChannel(player.CurrentChannel);
         Validator.ValidateSong(player.CurrentSong);
     }
 }
Example #30
0
        public static void Main(string[] args)
        {
            JObject config = JObject.Parse(File.ReadAllText("Game.json"));
            Base = (string) config["auth"]["url"];
            int topic = (int) config["auth"]["thread"];
            int skip = (int) config["state"]["startpost"];
            foreach(string player in config["state"]["players"]) {
                Player p = new Player() { Name = player };
                Players[player.ToLower()] = p;
            }

            foreach(JObject post in GetPosts(topic)) {
                if((int) post["post_number"] < skip)
                    continue;
                var actor = ((string) post["username"]).ToLower();
                if(Players.ContainsKey(actor)) {
                    Players[actor].LastPost = DateTime.Parse((string) post["created_at"]);
                    Players[actor].Postcount++;
                    ProcessActions(post, ProcessAction);
                }
            }

            var Quiets = "<table><tr><th>Player</th><th>Posts</th></tr>" + String.Join("",
                             Players.Values.OrderByDescending(p => p.Postcount).Select(p => string.Format("<tr><td>{0}</td><td>{1}</td></tr>",
                                 p.Name, p.Postcount))) + "</table>";

            var t = new PostTemplate();
            t.Session = new Dictionary<string, object>();
            t.Session["Day"] = (int) config["state"]["day"];
            t.Session["Motd"] = (string) config["state"]["motd"];
            t.Session["Deadline"] = DateTime.Parse((string) config["state"]["deadline"]);
            t.Session["Players"] = Players.Values;
            t.Session["Topic"] = topic;

            t.Initialize();
            var vcpost = t.TransformText();
            System.Console.Write(vcpost);

            System.Diagnostics.Debugger.Break();
        }