protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.LobbyLayout); Button CreateGame = FindViewById <Button>(Resource.Id.Create); Button JoinGame = FindViewById <Button>(Resource.Id.Join); TextView error = FindViewById <TextView>(Resource.Id.er); CreateGame.Click += (object sender, EventArgs e) => { comm c = new comm(); if (c.GET("Players", GlobalVariables.playername).active_game != "" || c.GET("Players", GlobalVariables.playername).active_game != null) { CreateGame.Enabled = false; error.Text = "you are already a part of a game please join that one"; } else { Intent CreateGameIntent = new Intent(this, typeof(GameCreation)); StartActivity(CreateGameIntent); } }; JoinGame.Click += (object sender, EventArgs e) => { Intent Join = new Intent(this, typeof(JoinGame)); StartActivity(Join); }; }
protected override void OnCreate(Bundle savedInstanceState) { SetContentView(Resource.Layout.CreateGame); Button CreateTable = FindViewById <Button>(Resource.Id.CreateTable); EditText TableName = FindViewById <EditText>(Resource.Id.TName); EditText TablePass = FindViewById <EditText>(Resource.Id._password); TextView errors = FindViewById <TextView>(Resource.Id.errors); EditText NumOfPlayers = FindViewById <EditText>(Resource.Id.NumOfPlayers); string tn = ""; string tp = ""; int n = 0; CreateTable.Click += (object sender, EventArgs e) => { tp = TablePass.Text; tn = TableName.Text; try { n = int.Parse(NumOfPlayers.Text); } catch { errors.Text = "please enter a number in the number of players tab"; } if (tn != "" && tp != "" && n <= 10 && n >= 5) { comm c = new comm(); coll data = new coll(); if (!c.GETF("Games", "\"name\"", tn).Contains("total=0")) { errors.Text = "game name already exists please use a different one"; } else { data.name = tn; GlobalVariables.Gamename = tn; data.status = "login"; data.game_password = tp; data.NumberOfPlayers = n; data.players.Add(MainActivity.playername); c.POST("Games", data); coll d2 = new coll(); d2.active_game = tn; c.PATCH("Players", GlobalVariables.playername, d2); Intent Lobbyintent = new Intent(this, typeof(Ceremony)); StartActivity(Lobbyintent); } } else { errors.Text = "wrong inputs, please follow the instructions"; } }; }
private Player[] makePlayerArray() { comm c = new comm(); List <string> pps = c.GET("Games", GlobalVariables.Gamename).players; int nop = c.GET("Games", GlobalVariables.Gamename).NumberOfPlayers; Player[] p = new Player[nop]; for (int i = 0; i < nop; i++) { p[i] = new Player(pps[i]); } return(p); }
public string[] ManageCeremony() { coll data = new coll(); data.status = "ceremony"; comm c = new comm(); c.PATCH("Games", GlobalVariables.Gamename, data); int nop = c.GET("Games", GlobalVariables.Gamename).NumberOfPlayers; string[] infos = new string[nop]; tekes Cer = new tekes(nop, makePlayerArray()); // add players array Cer.assign(); // assign each player his role Player[] p = Cer.players; coll d = new coll(); for (int i = 0; i < nop; i++) { d = new coll(); d.role = p[i].GetKind();// assigns the player his role from the random role generator if (i == 0) { d.is_leader = true; } if (p[i].GetKind() == "merlin")//merlin info problem { d.member = "good"; } else if (p[i].GetKind() == "mordred" || p[i].GetKind() == "assassin")//mordred info problem { d.member = "evil"; } else { d.member = p[i].GetKind(); } d.number = i; infos[i] = "you're: " + p[i].GetKind() + " " + p[i].getInfo(Cer); d.location = infos[i]; string reply = c.PATCH("Players", p[i].playerName, d); } return(infos); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Main_Game); Button info = FindViewById <Button>(Resource.Id.info2); Button missions = FindViewById <Button>(Resource.Id.missions); Button Refresh = FindViewById <Button>(Resource.Id.refresh2); Button Submit = FindViewById <Button>(Resource.Id.submit); //decision buttons int approveCount = 0; int successCount = 0; // Button Approve = FindViewById<Button>(Resource.Id.Approve); // Button Reject = FindViewById<Button>(Resource.Id.Reject); Button Fail = FindViewById <Button>(Resource.Id.Fail); Button Success = FindViewById <Button>(Resource.Id.Succes); string decision = "", decision2 = ""; TextView feedback = FindViewById <TextView>(Resource.Id.feedback); comm c = new comm(); int nop = c.GET("Games", GlobalVariables.Gamename).NumberOfPlayers; string playrname = GlobalVariables.playername; List <string> votes = c.GET("Games", GlobalVariables.Gamename).previous_leaders; string gamename = GlobalVariables.Gamename; info.Click += (object sender, EventArgs e) => { Intent cer = new Intent(this, typeof(Ceremony)); StartActivity(cer); }; missions.Click += (object sender, EventArgs e) => { //TO DO: add mission intent }; if (c.GET("Games", gamename).status == "game") { if (playrname == c.GET("Games", gamename).leader) { feedback.Text = "you are the leader! taking you to pick a team..."; System.Threading.Thread.Sleep(2000); Intent sPlayers = new Intent(this, typeof(sPlayers)); StartActivity(sPlayers); } else { feedback.Text = "please refresh when you have been told the team has been picked then vote"; } } if (c.GET("Games", gamename).status == "appORrej" || c.GET("Players", playrname).online == true) { Fail.Text = "Reject"; Fail.Enabled = true; Success.Text = "Approve"; Success.Enabled = true; Success.Click += (object sender, EventArgs e) => { decision = "Approve"; feedback.Text = "you are approving"; }; Fail.Click += (object sender, EventArgs e) => { decision = "Reject"; feedback.Text = "you are rejecting"; }; } Submit.Click += (object sender, EventArgs e) => { if (decision != "") { approveCount++; Fail.Enabled = false; Success.Enabled = false; coll Data = new coll(); if (votes.Count != nop && approveCount == 1) { votes.Add(decision); } c.PATCH("Games", gamename, Data); Data.previous_leaders = votes; coll pD = new coll(); pD.online = false; c.PATCH("Games", gamename, Data); c.PATCH("Players", playrname, pD); feedback.Text = "when everyone has voted please press REFRESH"; } else { feedback.Text = "please select approve or reject"; } }; if (votes.Count == nop) { Fail.Enabled = false; Success.Enabled = false; Fail.Text = "Fail"; Success.Text = "Succes"; coll da = new coll(); int x = c.GET("Games", gamename).vote; int countA = 0; int countR = 0; for (int i = 0; i < nop; i++) { if (votes[i] == "Approve") { countA++; } else { countR++; } } if (countA > countR || x == 5) { string status = "FailOrSucc"; da.team_approved = true; da.status = status; int countTeam = c.GET("Games", gamename).team.Count; votes = new List <string>(); Fail.Enabled = false; Success.Enabled = false; if (c.GET("Game", gamename).team.Contains(playrname)) { Success.Enabled = true; if (c.GET("Players", playrname).member == "evil") { Fail.Enabled = true; } else { Fail.Text = "Fail (only evils can fail a mission)"; } Success.Click += (object sender, EventArgs e) => { decision2 = "Success"; feedback.Text = "you are voting success"; }; Fail.Click += (object sender, EventArgs e) => { decision2 = "Fail"; feedback.Text = "you are voting fail"; }; int mission = 0; Submit.Click += (object sender, EventArgs e) => { if (decision2 != "") { successCount++; Fail.Enabled = false; Success.Enabled = false; coll Data = new coll(); votes.Add(decision2); Data.previous_leaders = votes; mission = c.GET("Games", gamename).mission + 1;; Data.mission = mission; c.PATCH("Games", gamename, Data); feedback.Text = "please Refresh, results are on mission info "; decision2 = ""; feedback.Text = "when everyone has voted please press REFRESH"; if (successCount != 1) { feedback.Text = "you cant vote more than once"; } } else { feedback.Text = "please select Fail or Success"; } }; if (votes.Count == countTeam) { coll d = new coll(); string result = "Success"; int countF = 0, countS = 0; for (int i = 0; i < countTeam; i++) { if (votes[i] == "Fail") { countF++; result = "Fail"; } else { countS++; } } d.result = result; d.success = countS; d.failure = countF; d.name = gamename + mission; d.mission = mission; d.active_game = gamename; c.POST("Missions", d); } } if (x == 5) { coll d = new coll(); d.vote = 1; c.PATCH("Games", gamename, d); } coll pd2 = new coll(); pd2.online = true; c.PATCH("Players", playrname, pd2); } else { coll d = new coll(); d.vote = x + 1; d.team = new List <string>(); d.previous_leaders = new List <string>(); feedback.Text = "please refresh"; } } Refresh.Click += (object sender, EventArgs e) => { info.Click += (object s, EventArgs e2) => { Intent cer = new Intent(this, typeof(Ceremony)); StartActivity(cer); }; missions.Click += (object s, EventArgs e2) => { //TO DO: add mission intent }; if (c.GET("Games", gamename).status == "game") { if (playrname == c.GET("Games", gamename).leader) { feedback.Text = "you are the leader! taking you to pick a team..."; System.Threading.Thread.Sleep(2000); Intent sPlayers = new Intent(this, typeof(sPlayers)); StartActivity(sPlayers); } else { feedback.Text = "please refresh when you have been told the team has been picked then vote"; } } if (c.GET("Games", gamename).status == "appORrej" || c.GET("Players", playrname).online == true) { Fail.Text = "Reject"; Fail.Enabled = true; Success.Text = "Approve"; Success.Enabled = true; Success.Click += (object s, EventArgs e2) => { decision = "Approve"; feedback.Text = "you are approving"; }; Fail.Click += (object s, EventArgs e2) => { decision = "Reject"; feedback.Text = "you are rejecting"; }; } Submit.Click += (object s, EventArgs e2) => { if (decision != "") { approveCount++; Fail.Enabled = false; Success.Enabled = false; coll Data = new coll(); if (votes.Count != nop && approveCount == 1) { votes.Add(decision); } c.PATCH("Games", gamename, Data); Data.previous_leaders = votes; coll pD = new coll(); pD.online = false; c.PATCH("Games", gamename, Data); c.PATCH("Players", playrname, pD); feedback.Text = "when everyone has voted please press REFRESH"; } else { feedback.Text = "please select approve or reject"; } }; if (votes.Count == nop) { Fail.Enabled = false; Success.Enabled = false; Fail.Text = "Fail"; Success.Text = "Succes"; coll da = new coll(); int x = c.GET("Games", gamename).vote; int countA = 0; int countR = 0; for (int i = 0; i < nop; i++) { if (votes[i] == "Approve") { countA++; } else { countR++; } } if (countA > countR || x == 5) { string status = "FailOrSucc"; da.team_approved = true; da.status = status; int countTeam = c.GET("Games", gamename).team.Count; votes = new List <string>(); Fail.Enabled = false; Success.Enabled = false; if (c.GET("Game", gamename).team.Contains(playrname)) { Success.Enabled = true; if (c.GET("Players", playrname).member == "evil") { Fail.Enabled = true; } else { Fail.Text = "Fail (only evils can fail a mission)"; } Success.Click += (object s, EventArgs e2) => { decision2 = "Success"; feedback.Text = "you are voting success"; }; Fail.Click += (object s, EventArgs e2) => { decision2 = "Fail"; feedback.Text = "you are voting fail"; }; int mission = 0; Submit.Click += (object s, EventArgs e2) => { if (decision2 != "") { successCount++; Fail.Enabled = false; Success.Enabled = false; coll Data = new coll(); votes.Add(decision2); Data.previous_leaders = votes; mission = c.GET("Games", gamename).mission + 1;; Data.mission = mission; c.PATCH("Games", gamename, Data); decision2 = ""; feedback.Text = "when everyone has voted please press REFRESH"; if (successCount != 1) { feedback.Text = "you cant vote more than once"; } } else { feedback.Text = "please select Fail or Success"; } }; if (votes.Count == countTeam) { coll d = new coll(); string result = "Success"; int countF = 0, countS = 0; for (int i = 0; i < countTeam; i++) { if (votes[i] == "Fail") { countF++; result = "Fail"; } else { countS++; } } d.result = result; d.success = countS; d.failure = countF; d.name = gamename + mission; d.mission = mission; d.active_game = gamename; c.POST("Missions", d); feedback.Text = "please Refresh, results are on mission info "; } } if (x == 5) { coll d = new coll(); d.vote = 1; c.PATCH("Games", gamename, d); } coll pd2 = new coll(); pd2.online = true; c.PATCH("Players", playrname, pd2); } else { coll d = new coll(); d.vote = x + 1; d.team = new List <string>(); d.previous_leaders = new List <string>(); feedback.Text = "please refresh"; } } }; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.GameCeremony); Button Play = FindViewById <Button>(Resource.Id.Move); Button Refresh = FindViewById <Button>(Resource.Id.Refresh); Button BeginC = FindViewById <Button>(Resource.Id.cere); TextView info = FindViewById <TextView>(Resource.Id.info); TextView Status = FindViewById <TextView>(Resource.Id.status); string playrname = GlobalVariables.playername; string gamename = GlobalVariables.Gamename; comm c = new comm(); string playerInfo = ""; string status = ""; Play.Enabled = true; info.Text = "Your info: " + c.GET("Players", playrname).location; if (c.GET("Games", gamename).status == "login" && c.GET("Games", gamename).players.Count == c.GET("Games", gamename).NumberOfPlayers) { BeginC.Enabled = true; status = "Bceremony"; } if (status == "Bceremony") { Play.Enabled = false; status = "Bceremony"; BeginC.Click += (object sender, EventArgs e) => { status = "ceremony"; BeginC.Enabled = false; coll data = new coll(); Status.Text = "begining ceremony, keep tight"; string[] infos = ManageCeremony(); playerInfo = infos[c.GET("Games", gamename).number]; data.status = "game"; status = "game"; data.mission = 1; c.PATCH("Games", gamename, data); info.Text += " " + playerInfo; Play.Enabled = true; BeginC.Enabled = false; Refresh.Enabled = false; }; } Play.Click += (object sender, EventArgs e) => { coll d2 = new coll(); coll d3 = new coll(); d3.is_leader = true; d2.leader = c.GET("Games", gamename).players[0]; GlobalVariables.Leader = 0; int x = c.GET("Games", gamename).vote; if (x != 1 || x != 2 || x != 2 || x != 3 || x != 4 || x != 5) { d2.vote = 1; } int nop = c.GET("Games", GlobalVariables.Gamename).NumberOfPlayers; d2.previous_leaders = new List <string>(); c.PATCH("Games", gamename, d2); c.PATCH("Players", playrname, d3); Intent Game = new Intent(this, typeof(Game)); StartActivity(Game); }; Refresh.Click += (object sender, EventArgs e) => { int nop = c.GET("Games", gamename).NumberOfPlayers; if (c.GET("Games", gamename).status == "login" && c.GET("Games", gamename).players.Count == c.GET("Games", gamename).NumberOfPlayers) { BeginC.Enabled = true; status = "Bceremony"; } if (status == "Bceremony") { Play.Enabled = false; BeginC.Enabled = true; BeginC.Click += (object s, EventArgs e2) => { status = "ceremony"; BeginC.Enabled = false; coll data = new coll(); Status.Text = "begining ceremony, keep tight"; string[] infos = ManageCeremony(); playerInfo = infos[c.GET("Games", gamename).number]; info.Text += " " + playerInfo; Play.Enabled = true; data.status = "game"; status = "game"; data.mission = 1; c.PATCH("Games", gamename, data); BeginC.Enabled = false; Refresh.Enabled = false; }; } info.Text = "Your info: " + c.GET("Players", playrname).location; }; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.JoinGame); EditText pass = FindViewById <EditText>(Resource.Id.pass); EditText TableN = FindViewById <EditText>(Resource.Id.TableN); Button join = FindViewById <Button>(Resource.Id.EnterG); TextView errors = FindViewById <TextView>(Resource.Id.e); string tn = "", p = ""; join.Click += (object sender, EventArgs e) => { tn = TableN.Text; p = pass.Text; comm c = new comm(); coll update = new coll(); if (tn != "" && p != "") { if (c.GET("Games", tn).name == null) { errors.Text = "sorry, the table name does not exist on our data base, please try again"; } else { if (c.GET("Games", tn).game_password == p) { if (c.GET("Games", tn).players.Contains(GlobalVariables.playername)) { GlobalVariables.Gamename = tn; Intent ci = new Intent(this, typeof(Ceremony)); StartActivity(ci); } else if (c.GET("Games", tn).players.Count < c.GET("Games", tn).NumberOfPlayers) { GlobalVariables.Gamename = tn; List <string> pl = c.GET("Games", tn).players; pl.Add(GlobalVariables.playername); update.players = pl; c.PATCH("Games", tn, update); coll d2 = new coll(); d2.active_game = tn; c.PATCH("Players", GlobalVariables.playername, d2); Intent CeremonyIntent = new Intent(this, typeof(Ceremony)); StartActivity(CeremonyIntent); } } else { errors.Text = "table is either full or you have entered the wrong password"; } //update.players = new List<string> { "me", "update", "Arthur", "Betty", "koren", "yakov" }; //update.variant = new Variant { mordred = true, lady = true, morgana = true, percival = true, excalibur = true }; } } else { errors.Text = "you can not enter empty values"; } }; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); // Get our UI controls from the loaded layout: EditText NickName = FindViewById <EditText>(Resource.Id.nickname); EditText pass = FindViewById <EditText>(Resource.Id._pass); TextView error = FindViewById <TextView>(Resource.Id.errors); Button Enter = FindViewById <Button>(Resource.Id.Enter); // Add code to translate number string nickname, passW, errorM; Enter.Click += (object sender, EventArgs e) => { comm c = new comm(); nickname = NickName.Text; passW = pass.Text; if (nickname == "" || passW == "") { errorM = "Invalid inputs please try again, password or username can not be empty"; error.Text = errorM; } if (nickname.Contains(" ") || passW.Contains(" ")) { error.Text = "inputs can not include spcaes"; } if ((c.GET("Players", nickname).password) != null && c.GET("Players", nickname).password != passW) { error.Text = "username already exists, please choose a different one or enter a correct password for that username"; } else if ((c.GET("Players", nickname).password) != null && c.GET("Players", nickname).password == passW) { GlobalVariables.playername = nickname; string game = c.GET("Players", nickname).active_game; if (game.Length >= 1) { GlobalVariables.Gamename = game; Intent Cer = new Intent(this, typeof(Ceremony)); StartActivity(Cer); } else { Intent Lobbyintent = new Intent(this, typeof(Lobby)); StartActivity(Lobbyintent); } } else if (!(nickname.Contains(" ") || passW.Contains(" "))) { GlobalVariables.playername = nickname; coll data = new coll(); data.name = nickname; data.password = passW; string post = c.POST("Players", data); Intent Lobbyintent = new Intent(this, typeof(Lobby)); StartActivity(Lobbyintent); } }; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.sPlayers); TextView msn = FindViewById <TextView>(Resource.Id.msn); TextView fdb = FindViewById <TextView>(Resource.Id.fdb); CheckBox[] buttons = new CheckBox[10]; buttons[0] = FindViewById <CheckBox>(Resource.Id.p1); buttons[1] = FindViewById <CheckBox>(Resource.Id.p2); buttons[2] = FindViewById <CheckBox>(Resource.Id.p3); buttons[3] = FindViewById <CheckBox>(Resource.Id.p4); buttons[4] = FindViewById <CheckBox>(Resource.Id.p5); buttons[5] = FindViewById <CheckBox>(Resource.Id.p6); buttons[6] = FindViewById <CheckBox>(Resource.Id.p7); buttons[7] = FindViewById <CheckBox>(Resource.Id.p8); buttons[8] = FindViewById <CheckBox>(Resource.Id.p9); buttons[9] = FindViewById <CheckBox>(Resource.Id.p10); Button submit = FindViewById <Button>(Resource.Id.sd); Player[] pps = makePlayerArray(); int nop = pps.Length; comm c = new comm(); string activeG = c.GET("Players", pps[0].playerName).active_game; int m = c.GET("Games", activeG).mission; double playersToTake = numP(nop, m); msn.Text += " " + (playersToTake); GlobalVariables.Leader = c.GET("Players", GlobalVariables.playername).number; string[] ps = new string[nop]; for (int i = 0; i < 10; i++) { if (i < nop) { buttons[i].Text = pps[i].GetplayerName(); ps[i] = pps[i].GetplayerName(); } else { buttons[i].Visibility = ViewStates.Gone; } } submit.Click += (object sender, EventArgs e) => { string[] players = new string[(int)playersToTake]; int countSelected = 0; for (int i = 0; i < 10; i++) { if (buttons[i].Checked == true) { countSelected++; } } if (countSelected == players.Length) { for (int i = 0, j = 0; i < 10; i++) { if (buttons[i].Checked) { players[j] = ps[i]; j++; } } coll data = new coll(); coll p1Data = new coll(); coll p2Data = new coll(); data.mission = m + 1; //////// not updating the leader and the game data.team = players.ToList(); if (playersToTake == 4.5 || playersToTake == 5.5) { data.fail_factor = 2; } else { data.fail_factor = 1; } data.team_count = (int)playersToTake; data.previous_leaders = new List <string>(nop); string bLead = c.GET("Games", activeG).players[GlobalVariables.Leader]; if (GlobalVariables.Leader == nop) { GlobalVariables.Leader = 0; } else { GlobalVariables.Leader++; } string lead = c.GET("Games", activeG).players[GlobalVariables.Leader]; data.leader = lead; data.status = "appORrej"; p1Data.is_leader = false; p2Data.is_leader = true; c.PATCH("Games", activeG, data); c.PATCH("Players", bLead, p1Data); System.Threading.Thread.Sleep(1000); c.PATCH("Players", lead, p2Data); fdb.Text += "going to vote"; Intent goVote = new Intent(this, typeof(Game)); StartActivity(goVote); } else { fdb.Text = "you have to select the amount of players listed above."; } }; }