// Use this for initialization void Start() { // Create the original team. Team team = new Team(); team.AddMember(new MemInfo("Anders", "Developer", 26)); team.AddMember(new MemInfo("Bill", "Developer", 46)); team.AddMember(new MemInfo("Steve", "CEO", 36)); Team clone = team.Clone() as Team; // Display the original team. GameLogger.Log("Original Team:"); GameLogger.Log(team.ToString()); // Display the cloned team. GameLogger.Log("Clone Team:"); GameLogger.Log(clone.ToString()); // Make changes. GameLogger.Log("*** Make a change to original team ***"); GameLogger.Log(Environment.NewLine); team.m_mems[0].m_nickname = "PM"; team.m_mems[0].m_age = 30; GameLogger.Log("modify team.m_mems[0] " + team.m_mems[0].ToString()); // Display the original team. GameLogger.Log("Original Team:"); GameLogger.Log(team.ToString()); // Display the cloned team. GameLogger.Log("Clone Team:"); GameLogger.Log(clone.ToString()); }
public void RemoveMemberTest() { string username = "******"; string password = "******"; Team test1 = new Team(); Team test2 = new Team(); User testuser1 = new User(username, password); User testuser2 = new User("testusername1", "testpassword1"); //check for when removemember passes bool success = test1.AddMember(testuser1); success = test1.AddMember(testuser2); success = test1.RemoveMember(testuser1); success = test2.AddMember(testuser1); Assert.AreEqual(test1.Userlist.Count, test2.Userlist.Count); //check for when removemember fails User testuser3 = new User("testusername2", "testpassword2"); success = test1.RemoveMember(testuser3); if (success == false) { Assert.AreEqual(test1.Userlist.Count, test2.Userlist.Count); } else { Assert.AreEqual(true, false); } }
public void AddMemberTest() { bool UsernamesEqual = false; string username = "******"; string password = "******"; //test for case where user does not exist in the team Team test1 = new Team(); Team test2 = new Team(); User testuser1 = new User(username, password); bool success = test1.AddMember(testuser1); test2.Userlist.Add(testuser1); test2.Roles.Add(false); if (test1.Userlist[0].username.Equals(test2.Userlist[0].username)) { UsernamesEqual = true; } Assert.AreEqual(UsernamesEqual, true); //test case for where user does exist in the team success = test1.AddMember(testuser1); test2.Userlist.Add(testuser1); test2.Roles.Add(false); Assert.AreNotEqual(test1.Userlist.Count, test2.Userlist.Count); }
public void CreateNewTeam(InvitationTemplate activeInvitation) { if (GetActiveTeamByUnit(activeInvitation.Owner.Id) != null || GetActiveTeamByUnit(activeInvitation.Target.Id) != null) { // TODO - ERROR MESSAGE ALREADY HAVE TEAM return; } var newTeam = new Team { Id = TeamIdManager.Instance.GetNextId(), OwnerId = activeInvitation.Owner.Id, IsParty = activeInvitation.IsParty, LootingRule = new LootingRule() }; if (newTeam.AddMember(activeInvitation.Owner).Item1 == null || newTeam.AddMember(activeInvitation.Target).Item1 == null) { return; } _activeTeams.Add(newTeam.Id, newTeam); // TODO - CHAT JOIN CHANNEL??? activeInvitation.Owner.SendPacket(new SCJoinedTeamPacket(newTeam)); activeInvitation.Owner.InParty = true; activeInvitation.Target.SendPacket(new SCJoinedTeamPacket(newTeam)); activeInvitation.Target.InParty = true; newTeam.BroadcastPacket(new SCTeamPingPosPacket(true, new Point(0, 0, 0), 0)); // TODO - GET "REAL" POSITION FROM DUMP }
public void getFitnessTest() { //make a test TeamMember mem1 = new TeamMember("Mem1"); TeamMember mem2 = new TeamMember("Mem2"); mem1.preferredTeammates.Add(mem2); mem2.unprefferedTeammates.Add(mem1); Team t1 = new Team(); t1.AddMember(mem1); t1.AddMember(mem2); Assert.AreEqual(Settings.PreferredTeammateWeight, mem1.getFitness()); Assert.AreEqual(Settings.UnpreferredTeammateWeight, mem2.getFitness()); }
public void TeamAddMemberTest() { Team a = new Team("A"); DateTime departure = new DateTime(2014, 11, 20); TeamMember MemberA = new TeamMember("John", Trainings.firstResponder, departure); TeamMember MemberB = new TeamMember("Alex", Trainings.firstAid, departure); a.AddMember(MemberA); a.AddMember(MemberB); Assert.AreEqual(a.getMember(2), null); Assert.AreEqual(a.getMember(0), MemberA); Assert.AreEqual(a.getMember(1), MemberB); }
public void TeamAddMemberTest_Full() { Team a = new Team("A"); DateTime departure = new DateTime(2014, 11, 20); TeamMember MemberA = new TeamMember("John", Trainings.firstResponder, departure); TeamMember MemberB = new TeamMember("Alex", Trainings.firstAid, departure); TeamMember MemberC = new TeamMember("Kelso", Trainings.medicine, departure); TeamMember MemberD = new TeamMember("Dorian", Trainings.medicine, departure); a.AddMember(MemberA); a.AddMember(MemberB); a.AddMember(MemberC); Assert.IsFalse(a.AddMember(MemberD)); }
public void GetHighestLevelOfTrainingTest() { Team a = new Team("A"); DateTime departure = new DateTime(2014, 11, 20); TeamMember MemberA = new TeamMember("John", Trainings.firstResponder, departure); TeamMember MemberB = new TeamMember("Alex", Trainings.firstAid, departure); TeamMember MemberC = new TeamMember("Kelso", Trainings.medicine, departure); a.AddMember(MemberA); a.AddMember(MemberB); Assert.AreEqual(a.getHighestLevelOfTraining(), Trainings.firstResponder); a.AddMember(MemberC); Assert.AreEqual(a.getHighestLevelOfTraining(), Trainings.medicine); }
/// <summary> /// 创建群组 /// </summary> /// <param name="teamName"></param> /// <returns></returns> public static bool CreateTeam(string teamName) { if (string.IsNullOrWhiteSpace(teamName)) { ShowError("组名不能为空!"); return(false); } if (_teamList.Any(d => d.TeamName == teamName)) { ShowError("组名不能重复!"); return(false); } Team info = new Team(); info.TeamId = Guid.NewGuid().ToString(); info.TeamName = teamName; info.AddMember(LoginUserInfo.UserName, LoginUserInfo.DisplayName); _teamList.Add(info); ShowSuccess("分组建立成功"); IsTeamChatChanged = true; return(true); }
public void AddMemberShould_MemberAdded() { var member = new FakeMember(); var team = new Team("Team1"); team.AddMember(member); Assert.AreEqual(team.Members.Count, 1); }
public void AddMobToTeam(string name, NetworkViewID id) { Character character = GameObject.Find(name).GetComponent <Character>(); character.networkView.viewID = id; character.Type = Character.Types.AI; character.name = character.name + character.GetInstanceID().ToString(); Team.AddMember(character); }
public GameObject InstantiatePlayer() { Player player = GameObject.Instantiate <GameObject>(playerPrefab).GetComponent <Player>(); playerID = playerCount++; player.name = playerName; player.playerData = this; playerTeam.AddMember(player); return(player.gameObject); }
public void AddExistingMemberShouldNotModifyCollection() { // Arrange var id = TeamId.New; var name = new Name("name"); var entity = new Team(id, name); var memberId = Guid.NewGuid(); var member = new Member(memberId); entity.AddMember(member); // Act entity.AddMember(member); // Assert entity.Members.Count.Should().Be(1); entity.Members.ElementAt(0).Should().Be(member); }
public void ContainMembers() { //Arrange string name = "TestTeam"; string memberName = "TestMember"; var member = new Member(memberName); //Act var sut = new Team(name); sut.AddMember(member); //Assert Assert.AreEqual(sut.Members.Count, 1); }
public void SetLeaderTest() { User user1 = new User("username1", "password1"); User user2 = new User("username2", "password2"); User user3 = new User("username3", "password3"); User user4 = new User("username4", "password4"); Team team1 = new Team(); team1.AddMember(user1); team1.AddMember(user2); team1.AddMember(user3); team1.AddMember(user4); team1.Roles.Add(true); team1.Roles.Add(false); team1.Roles.Add(false); team1.Roles.Add(false); team1.setLeader(user2); Assert.AreEqual(true, team1.Roles[1]); }
public static async Task CreateTeamMenu(UserAccount user, IUserMessage message, IEmote emote, ContextIds idList) { switch (emote.Name.ToLower()) { case "back1": user.RemoveAllReactionMessages(9); user.RemoveAllReactionMessages(1); await message.RemoveAllReactionsAsync(); await message.ModifyAsync(m => { m.Embed = MonEmbedBuilder.MainMenu(user); m.Content = ""; }); await MessageHandler.MenuEmojis(message); user.ReactionMessages.Add(message.Id, 1); break; case "team": Team t = new Team(true); t.AddMember(user); TownHandler.GetTown(user.Char.CurrentGuildId).Teams.Add(t); if (user.ExpectedInput == 5) { user.ExpectedInput = -1; user.ExpectedInputLocation = 0; } user.RemoveAllReactionMessages(9); user.RemoveAllReactionMessages(7); await message.RemoveAllReactionsAsync(); await message.ModifyAsync(m => { m.Embed = MonEmbedBuilder.TeamMenu(user); m.Content = ""; }); await MessageHandler.TeamMenuEmojis(message, user); break; case "invite": await message.ModifyAsync(m => { m.Content = "**Tag someone in the team you want to join. The team must be open.**"; }); user.ExpectedInput = 5; user.ExpectedInputLocation = message.Channel.Id; break; default: break; } }
public async Task UpdateTeamsWithDeletedMembersShouldSucceed() { // Arrange var memberId = Guid.NewGuid(); var member2Id = Guid.NewGuid(); var team1 = new Team(new TeamId(Guid.NewGuid().ToString()), new Name("anyName1")); var team2 = new Team(new TeamId(Guid.NewGuid().ToString()), new Name("anyName2")); var member = new Member(memberId); var member2 = new Member(member2Id); team1.AddMember(member); team1.AddMember(member2); team2.AddMember(member); team2.AddMember(member2); await _repository.CreateAsync(team1); await _repository.CreateAsync(team2); var teamList = RepositoryHelper.ForTeam.GetTeams().ToList(); // Act foreach (var item in teamList) { item.RemoveMember(memberId); await _repository.UpdateAsync(item); } // Assert var updatedTeamList = RepositoryHelper.ForTeam.GetTeams().ToList(); updatedTeamList.Count(x => x.Members.Any(y => y == member)).Should().Be(0); updatedTeamList.Count(x => (x.Members.Count > 0)).Should().Be(2); updatedTeamList.Should().NotContain(x => (x.Members.Contains(member))); updatedTeamList.Should().OnlyContain(x => (x.Members.Contains(member2))); }
public void getLeaderTest() { User user1 = new User("username1", "password1"); User user2 = new User("username2", "password2"); User user3 = new User("username3", "password3"); User user4 = new User("username4", "password4"); User teamleader = new User(null, null); Team team1 = new Team(); team1.AddMember(user1); team1.AddMember(user2); team1.AddMember(user3); team1.AddMember(user4); team1.Roles.Add(true); team1.Roles.Add(false); team1.Roles.Add(false); team1.Roles.Add(false); teamleader = team1.getLeader(); Assert.AreEqual(teamleader, user2); }
public League(List<TeamMember> pop, int numTeams) { this.numTeams = numTeams; for(int i = 0; i < pop.Count; i++) { if(teams.Count < numTeams) { Team t1 = new Team(); t1.AddMember(pop.ElementAt(i)); teams.Add(t1); } else { teams.ElementAt(i % numTeams).AddMember(pop.ElementAt(i)); } } }
private Team CreateTeam(Character leader) { Team team = null; for (int i = 0; i < this.Teams.Count; i++) { team = this.Teams[i]; if (team.Members.Count == 0) { team.AddMember(leader); return(team); } } team = new Team(leader); this.Teams.Add(team); team.Id = this.Teams.Count; return(team); }
public async Task CreateShouldSucceed() { // Arrange var id = TeamId.New; var name = new Name("name"); var team = new Team(id, name); var image = "image"; team.SetImage(image); var description = (Description)"description"; team.SetDescription(description); var layout = new Layout(Guid.NewGuid()); team.SetLayout(layout); var memberId = Guid.NewGuid(); var member = new Member(memberId); team.AddMember(member); // Act await _repository.CreateAsync(team); // Assert var data = RepositoryHelper.ForTeam.GetTeams(); data.Should().HaveCount(1); var result = data.First(); result.Id.Should().Be(id); result.Name.Should().Be(name); result.Image.Should().Be(image); result.Description.Should().Be(description); result.DriverWait.Should().Be(DriverWait.Unspecified); result.Layout.Should().Be(layout); result.Members.Should().NotBeNull(); result.Members.Should().HaveCount(1); result.Members.First().Should().Be(member); }
public void ClearMembersShouldSucceed() { // Arrange var id = TeamId.New; var name = new Name("name"); var entity = new Team(id, name); var memberId = Guid.NewGuid(); var member = new Member(memberId); entity.AddMember(member); // Act entity.ClearMembers(); // Assert entity.Members.Count.Should().Be(0); }
private void Spawn(GameObject mob) { Vector3 newPosition = transform.position + new Vector3(Random.Range(-7, 10), 0, Random.Range(-6, 4)); Character character; if (!_net.IsServer) { character = ((GameObject)Instantiate(mob, newPosition, Quaternion.identity)).GetComponent <Character>(); } else { // Instantiate via network and add them on all clients to this bases team. character = ((GameObject)Network.Instantiate(mob, newPosition, Quaternion.identity, 0)).GetComponent <Character>(); networkView.RPC("AddMobToTeam", RPCMode.Others, character.name, character.networkView.viewID); } character.Type = Types.AI; character.name = character.name + character.GetInstanceID().ToString(); Team.AddMember(character); }
public async Task <Team> GetAsync(Guid id) { try { var findById = await _collection.FindAsync(doc => doc.Id == id); var teamClass = findById.FirstOrDefault(); if (teamClass == null) { throw Error.EntityNotFoundDb(); } var teamId = TeamId.With(teamClass.Id); var team = new Team(teamId, new Name(teamClass.Name)); team.SetImage(teamClass.Image); team.SetDescription((Description)teamClass.Description); team.SetImage(teamClass.Image); Layout layout = null; if (teamClass.Layout != null) { layout = new Layout(teamClass.Layout.Id); } team.SetLayout(layout); team.SetFilterContent(teamClass.FilterContent); foreach (var member in teamClass.Members) { team.AddMember(new Member(member.Id)); } team.SetVersion(teamClass.Version); return(team); } catch (MongoCommandException ex) { Debug.WriteLine(ex); throw Error.GenericDb(ex); } catch (Exception ex) { Debug.WriteLine(ex); throw; } }
public static Team CreateTeamWithMembers(TeamId teamId, Name name, List <Guid> members) { // prepare var odataProvider = new TeamOdataProvider(); var writeRepository = new TeamWriteRepository(new PersistenceContext(new PersistenceConfiguration(RepositoryTestsHelper.ConnectionString))); var readRepository = new TeamReadRepository(new PersistenceContext(new PersistenceConfiguration(RepositoryTestsHelper.ConnectionString)), odataProvider); // create var team = new Team(teamId, name); foreach (var member in members) { team.AddMember(new Member(member)); } writeRepository.CreateAsync(team).GetAwaiter().GetResult(); // result var result = readRepository.GetAsync(teamId.GetGuid()).Result; return(result); }
public void RemoveUnexistingMemberShouldPassSilentlyWithoutAnyImpactOnCollection() { // Arrange var id = TeamId.New; var name = new Name("name"); var entity = new Team(id, name); var memberId = Guid.NewGuid(); var member = new Member(memberId); entity.AddMember(member); var memberToRemove = new Member(Guid.NewGuid()); // Act entity.RemoveMember(memberToRemove); // Assert entity.Members.Count.Should().Be(1); entity.Members.ElementAt(0).Should().Be(member); }
private async Task <TeamMembership> DangerouslyCreateTeamMembership(Team team, Guid userId, Guid roleId, string notes) { var role = await context.TeamRoles.FirstOrDefaultAsync(tr => tr.Id == roleId); if (role == null) { throw new NoNullAllowedException("Role cannot be null"); } var membership = team.AddMember(userId, roleId, notes); if (membership != null) { var permissions = role.Permissions.Select(p => AuthorizationHelper.GenerateARN(typeof(Team), team.Id.ToString(), p)).ToList(); var membershipPermission = AuthorizationHelper.GenerateARN(typeof(TeamMembership), membership.Id.ToString(), Shared.Permissions.TeamMembership.All); await this.authorizationService.AddPermission(userId, membershipPermission); await this.authorizationService.AddPermission(userId, permissions); await this.backgroundWorker.SendMessage(this.queues.Contact, new DTO.Marketing.ContactSync(userId), 5); } var gameId = team.Competition?.GameId; if (!gameId.HasValue) { gameId = (await context.Competitions.Include(c => c.Game).FirstOrDefaultAsync(c => c.Id.Equals(team.CompetitionId)))?.GameId; } if (gameId.HasValue) { await this.userUtils.GenerateExternalUserName(userId, gameId.Value); } return(membership); }
void InitTeam(Vector2 teamInitPosition, Vector2 teamDirection) { Team team = new Team(); team.Direction = teamDirection; int row = -1, col = 0; for (int i = 0; i < TeamBoidAmount; i++) { var boidGo = Instantiate(BoidPrefab); var boid = boidGo.GetComponent <Boid>(); if (RandomBorn) { boid.Position = new Vector2(Random.Range(-BornVariance, BornVariance), Random.Range(-BornVariance, BornVariance)); } else { if (i % TeamColumns == 0) { row += 1; col = 0; } else { col++; } float x = teamInitPosition.x + row * TeamRowGap + Random.Range(-TeamRowGapVar, TeamRowGapVar) + 2 * row * boid.Radius; float y = teamInitPosition.y + col * TeamColGap + Random.Range(-TeamColGapVar, TeamColGapVar) + 2 * col * boid.Radius; boid.Position = new Vector2(x, y); } boid.Path = Path; team.AddMember(boid); m_boids.Add(boid); } Teams.Add(team); }
public async Task <IEnumerable <Team> > ListAsync(string filter, int?skip, int?limit) { var filterDefinition = _teamOdataProvider.GetFilterDefinition(filter); IFindFluent <TeamClass, TeamClass> fluent = _collection.Find(filterDefinition); fluent = fluent.Skip(skip).Limit(limit); var teamClasses = await fluent.ToListAsync(); var result = new List <Team>(); foreach (var teamClass in teamClasses) { var team = new Team(TeamId.With(teamClass.Id), new Name(teamClass.Name)); team.SetImage(teamClass.Image); team.SetDescription((Description)teamClass.Description); team.SetImage(teamClass.Image); Layout layout = null; if (teamClass.Layout != null) { layout = new Layout(teamClass.Layout.Id); } team.SetLayout(layout); team.SetFilterContent(teamClass.FilterContent); foreach (var member in teamClass.Members) { team.AddMember(new Member(member.Id)); } team.SetVersion(teamClass.Version); result.Add(team); } return(result); }
void Start() { idolCreator.Init(); npcCreator.Init(); ConditionCheck cc = Global.GetComponent <ConditionCheck>(); cc.condition = () => { //Show.Log("checking victory " + Global.Get<Team>().members.Count + " / " + (npcs.Count + 1)); return(Global.GetComponent <Team>().members.Count >= npcCreator.npcs.Count + 1); }; cc.action = () => { Tokenizer tok = new Tokenizer(); DialogManager.Instance.StartDialog(this, tok, "win message"); tok.ShowErrorTo(DialogManager.ActiveDialog.ShowError); DialogManager.Instance.Show(); }; //Show.Log("finished initializing " + this); Team team = Global.GetComponent <Team>(); team.AddMember(firstPlayer); EnsureExplorer(firstPlayer); maze.stage = -1; GenerateNext(); }
protected virtual Member AddMemberToTeam(Member member, Team team, Account associatedAccount) { Assert.IsNotNull(member); Assert.IsValidKey(member.Email); Assert.IsValidKey(member.Name); Assert.IsValid(team); Assert.AreEqual(team.ID, member.TeamId); //HACK:为了确保新增成员时,团队内成员的Email以及成员关联的账号都唯一,所以这里通过锁来进行同步控制 this._locker.Require<Member>(); Assert.IsNull(_teamRepository.FindMemberBy(team, member.Email)); if (associatedAccount != null) { Assert.IsNull(_teamRepository.FindMemberBy(team, associatedAccount)); member.Associate(associatedAccount); } team.AddMember(member); _teamRepository.Update(team); return member; }
public void Crossover(IChromosome pair) { //strategy: //1. A new league is to be formed. //2. Team 1 is added from this league to the new league //3. From the input league, if a team is mutually exclusive to all team members in the new team. //4. From this league, do the same thing. //5. Continue until teams run out. //6. Fill in the remaining teams randomly. League L2 = (League)pair; League hybrid = new League(getPopulationClone(), numTeams); hybrid.teams = new List<Team>(); //hybrid.teams.Add(teams.ElementAt(0)); for(int i = 0; i < teams.Count; i++) { Team L1Team = teams.ElementAt(i); Team L2Team = L2.teams.ElementAt(i); //they should have the same number of teams. if (!hybrid.teamsHaveCommonMemberWith(L1Team)) hybrid.teams.Add(L1Team); if (!hybrid.teamsHaveCommonMemberWith(L2Team)) hybrid.teams.Add(L2Team); } //fill existing teams into hybrid. List<TeamMember> remainingMembers = hybrid.membersNotOnATeam(); int previousTeams = hybrid.teams.Count; int idx = 0; while (remainingMembers.Count > 0) { TeamMember remove = remainingMembers.ElementAt(0); remainingMembers.RemoveAt(0); if (numTeams > hybrid.teams.Count) { Team addTeam = new Team(); addTeam.AddMember(remove); hybrid.teams.Add(addTeam); } else { hybrid.teams.ElementAt(previousTeams - 1 + idx % (numTeams - previousTeams)).AddMember(remove); } idx++; } this.teams = hybrid.teams; //L.teams //crossover does nothing right now }
public static void AssignTeams(List<Employee> emps, List<Team> teams) // Sorts employees into their proper teams. { Team tempTeam = new Team(); Team targetTeam = null; string tempName; foreach (Employee e in emps) { tempName = e.GetTeam(); tempTeam.AddMember(e); tempTeam.TeamName = tempName; targetTeam = teams.Find(t => t.TeamName.Equals(tempName)); if (targetTeam == null) { teams.Add(tempTeam); tempTeam = new Team(); } else { targetTeam.AddMember(e); tempTeam = new Team(); } } foreach (Team t in teams) // Assign free agents reference { if(t.TeamName != "Free Agents") { t.FreeAgents = teams[teams.Count-1]; // Free agents is always the last team } } }
public static async Task ParseExpectedInput(SocketUserMessage message, UserAccount user, SocketCommandContext Context) { ContextIds idList = new ContextIds(Context); if ((user.ExpectedInputLocation == idList.ChannelId || user.ExpectedInputLocation == 0) && user.GetTeam() != null) { if (user.ExpectedInput == 0 || user.ExpectedInput == 1) { //Update the menu(s) of the person who sent the invite await UpdateMenu(user, message.Channel, 7, ""); /*foreach(KeyValuePair<ulong, int> kvp in user.ReactionMessages) * { * if(kvp.Value == 7) * { * IMessage teamMess = await message.Channel.GetMessageAsync(kvp.Key); * if(teamMess is IUserMessage) * { * IUserMessage userTeamMess = (IUserMessage)teamMess; * await userTeamMess.ModifyAsync(m => {m.Embed = MonEmbedBuilder.TeamMenu(user); m.Content = "";}); * } * } * }*/ } //Team Invite Sending if (user.ExpectedInput == 0) { foreach (SocketUser u in message.MentionedUsers) { var ua = UserHandler.GetUser(u.Id); if (ua.GetTeam() == null && ua.Char != null) { var m = await _client.GetGuild(idList.GuildId).GetTextChannel(idList.ChannelId).SendMessageAsync("", embed: MonEmbedBuilder.TeamInviteMenu(user, ua)).ConfigureAwait(false); await TeamInviteEmojis(m); ua.ReactionMessages.Add(m.Id, 10); ua.InviteMessages.Add(m.Id, user.UserId); } } } //Kick players from team else if (user.ExpectedInput == 1) { //Kick all players who are on the team as long as the user kicking has kick permissions foreach (SocketUser u in message.MentionedUsers) { var ua = UserHandler.GetUser(u.Id); if (ua.GetTeam() == user.GetTeam() && user.GetTeam().CanKick(user) && user != ua) { ua.GetTeam().KickMember(ua); } } //Update the user's currently active team menu await UpdateMenu(user, message.Channel, 7, ""); /*foreach(KeyValuePair<ulong, int> kvp in user.ReactionMessages) * { * if(kvp.Value == 7) * { * IMessage teamMess = await message.Channel.GetMessageAsync(kvp.Key); * if(teamMess is IUserMessage) * { * IUserMessage userTeamMess = (IUserMessage)teamMess; * await userTeamMess.ModifyAsync(m => {m.Embed = MonEmbedBuilder.TeamMenu(user); m.Content = "";}); * } * } * }*/ } //Edit team name else if (user.ExpectedInput == 2) { var team = user.GetTeam(); if (team.CanAccessSettings(user) && message.Content.Length < 64) { team.TeamName = message.Content; } await UpdateMenu(user, message.Channel, 8, ""); } //Add image url else if (user.ExpectedInput == 3) { var team = user.GetTeam(); if (team.CanAccessSettings(user)) { team.Picture = message.Content; } await UpdateMenu(user, message.Channel, 8, ""); } //Edit RGB else if (user.ExpectedInput == 4) { var team = user.GetTeam(); string updateContent = ""; if (team.CanAccessSettings(user)) { string str = message.Content; str = str.Replace(",", ""); string[] rgb = str.Split(' '); if (rgb.Count() == 3) { try { team.TeamR = Int32.Parse(rgb[0]); team.TeamG = Int32.Parse(rgb[1]); team.TeamB = Int32.Parse(rgb[2]); } catch (FormatException e) { Console.WriteLine(e.Message); updateContent = "**You didn't enter the RGB values correctly!**"; } } } await UpdateMenu(user, message.Channel, 8, updateContent); } user.ExpectedInput = -1; user.ExpectedInputLocation = 0; } //Expected inputs that do not require a team if (user.ExpectedInputLocation == idList.ChannelId || user.ExpectedInputLocation == 0) { //Join open team if (user.ExpectedInput == 5) { string updateContent = ""; var team = user.GetTeam(); UserAccount otherUser = null; if (message.MentionedUsers.Count != 0) { otherUser = UserHandler.GetUser(message.MentionedUsers.First().Id); } Team otherTeam = null; if (otherUser != null) { otherTeam = otherUser.GetTeam(); } if (otherTeam != null) { if (otherTeam.OpenInvite) { if (team == null) { otherTeam.AddMember(user); } else { updateContent = "**You already have a team!**"; } } else { updateContent = "**That team is not open invite!**"; } } else { updateContent = "**That person does not have a team!**"; } await UpdateMenu(user, message.Channel, 9, updateContent); } //Invite player(s) to a pvp lobby else if (user.ExpectedInput == 6) { foreach (SocketUser u in message.MentionedUsers) { var ua = UserHandler.GetUser(u.Id); if (ua.Char != null) { var m = await _client.GetGuild(idList.GuildId).GetTextChannel(idList.ChannelId).SendMessageAsync("", embed: MonEmbedBuilder.LobbyInviteMenu(user, ua)).ConfigureAwait(false); await TeamInviteEmojis(m); ua.ReactionMessages.Add(m.Id, 14); ua.InviteMessages.Add(m.Id, user.UserId); } } if (user.HasLobby()) { CombatCreationTool lobby = user.CombatLobby; await lobby.UpdateAllMenus(new List <ulong>(), idList, ""); } } else if (user.ExpectedInput == 7) { List <ulong> excludeUpdate = new List <ulong>(); foreach (SocketUser u in message.MentionedUsers) { var ua = UserHandler.GetUser(u.Id); if (ua.Char != null) { if (user.HasLobby()) { CombatCreationTool lobby = user.CombatLobby; lobby.RemovePlayer(ua); await UpdateMenu(ua, message.Channel, 12, "You have been kicked from the lobby."); excludeUpdate.Add(ua.UserId); } } } if (user.HasLobby()) { CombatCreationTool lobby = user.CombatLobby; await lobby.UpdateAllMenus(excludeUpdate, idList, ""); } } user.ExpectedInput = -1; user.ExpectedInputLocation = 0; } }
public void LevelGenerate(LevelState lvl) { Team team = Global.GetComponent <Team>(); EventBind checkGoal = new EventBind(this, nameof(GoalCheck)); if (lvl == null) { lvl = new LevelState(); lvl.stage = maze.stage; lvl.seed = random.Seed; lvl.idolsDistributed = idolCreator.idolsDistributed; if (inventory.GetItems() != null) { lvl.idolInventory = CodeConvert.Stringify(inventory.GetItems().ConvertAll(go => { Idol t = go.GetComponent <Idol>(); return(t ? t.intMetaData : null); })); } else { lvl.idolInventory = ""; } lvl.variables = CodeConvert.Stringify(mainDictionaryKeeper.Dictionary); lvl.allies = CodeConvert.Stringify(team.members.ConvertAll(m => npcCreator.npcs.FindIndex(n => n.gameObject == m))); levels.Add(lvl); } else { Tokenizer tokenizer = new Tokenizer(); // check if level is valid if (levels.IndexOf(lvl) < 0) { throw new Exception("TODO validate the level plz!"); } // set allies int[] allies; CodeConvert.TryParse(lvl.allies, out allies, null, tokenizer); team.Clear(); team.AddMember(firstPlayer); for (int i = 0; i < allies.Length; ++i) { int index = allies[i]; if (index < 0) { continue; } team.AddMember(npcCreator.npcs[index].gameObject); } // clear existing idols idolCreator.Clear(); // reset inventory to match start state inventory.RemoveAllItems(); int[][] invToLoad; CodeConvert.TryParse(lvl.idolInventory, out invToLoad, null, tokenizer); //Debug.Log(Show.Stringify(invToLoad,false)); Vector3 playerLoc = Global.GetComponent <CharacterControlManager>().localPlayerInterfaceObject.transform.position; for (int i = 0; i < invToLoad.Length; ++i) { int[] t = invToLoad[i]; if (t == null || t.Length == 0) { continue; } GameObject idol = idolCreator.CreateIdol(t[0], t[1], checkGoal); idol.transform.position = playerLoc + Vector3.forward; inventory.AddItem(idol); } // set stage maze.stage = lvl.stage; // set seed random.Seed = lvl.seed; // set variables HashTable_stringobject d = mainDictionaryKeeper.Dictionary; CodeConvert.TryParse(lvl.variables, out d, null, tokenizer); // set } MarkTouchdown.ClearMarkers(); clickToMove.ClearAllWaypoints(); seedLabel.text = "level " + maze.stage + "." + Convert.ToBase64String(BitConverter.GetBytes(random.Seed)); maze.Generate(random); Discovery.ResetAll(); idolCreator.Generate(checkGoal); int len = Mathf.Min(maze.floorTileNeighborHistogram[2], idolCreator.idolMaterials.Count); npcCreator.GenerateMore(len); if (testingPickups) { idolCreator.GenerateMoreIdols(checkGoal); } // TODO maze should have a list of unfilled tiles sorted by weight for (int i = 0; i < npcCreator.npcs.Count; ++i) { maze.PlaceObjectOverTile(npcCreator.npcs[i].transform, maze.floorTiles[maze.floorTileNeighborHistogram[1] + i]); } team.AddMember(firstPlayer); maze.PlaceObjectOverTile(team.members[0].transform, maze.floorTiles[maze.floorTiles.Count - 1]); Vector3 pos = team.members[0].transform.position; for (int i = 0; i < team.members.Count; ++i) { team.members[i].transform.position = pos; CharacterMove cm = team.members[i].GetComponent <CharacterMove>(); if (cm != null) { cm.SetAutoMovePosition(pos); cm.MoveForwardMovement = 0; cm.StrafeRightMovement = 0; } } UiText.SetColor(timer.gameObject, Color.white); timer.Start(); GoalCheck(null); nextLevelButton.SetActive(false); bestTimeLabel.gameObject.SetActive(false); }
public void setTeam(Team team) { this.team = team; team.AddMember(username); }