Beispiel #1
0
        public ActionResult DeleteRole(string id)
        {
            TeamRole role = Actor.Public.GetRole(id);
            NotificationViewModel notification = new NotificationViewModel();

            if (role.IsNotNull())
            {
                Actor.Public.DeleteRole(id, (bool ok) =>
                {
                    if (ok)
                    {
                        notification.Data             = NotificationData.YES;
                        notification.Content          = string.Format("角色:{0}删除成功", role.Name);
                        notification.NotificationType = NotificationType.Success;
                    }
                    else
                    {
                        notification.Data             = NotificationData.NO;
                        notification.Content          = string.Format("角色:{0}删除失败", role.Name);
                        notification.NotificationType = NotificationType.Error;
                    }
                });
            }
            else
            {
                notification.Data             = NotificationData.NO;
                notification.Content          = string.Format("角色ID:{0}不存在!", id);
                notification.NotificationType = NotificationType.Attention;
            }

            return(Result(notification));
        }
Beispiel #2
0
        public IHttpActionResult PutTeamRole(string id, TeamRole teamRole)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != teamRole.Name)
            {
                return(BadRequest());
            }

            db.Entry(teamRole).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TeamRoleExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
 public void SetupRoles(TeamRole role)
 {
     foreach (ParallaxScrolling bg in this.parallaxBackgrounds)
     {
         bg.SetMyRole(role);
     }
 }
Beispiel #4
0
    public JsonSetting[] handle(object api, Dictionary <string, string> mapper)
    {
        Player   player = api as Player;
        TeamRole t      = player.TeamRole;

        return(Utils.getOne(mapper["id"], null, new IdMapping().appendId(Lib.ID, t)));
    }
Beispiel #5
0
        public IHttpActionResult PostTeamRole(TeamRole teamRole)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.TeamRoles.Add(teamRole);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (TeamRoleExists(teamRole.Name))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = teamRole.Name }, teamRole));
        }
        public IEnumerable <PlayerIdentity> PlayerIdentitiesInMatch(Match match, TeamRole teamRole)
        {
            if (match is null)
            {
                throw new ArgumentNullException(nameof(match));
            }

            var matchTeam = match.Teams.SingleOrDefault(x => x.TeamRole == teamRole);

            if (matchTeam == null || !matchTeam.MatchTeamId.HasValue)
            {
                return(Array.Empty <PlayerIdentity>());
            }

            var comparer = new PlayerIdentityEqualityComparer();

            var battingInnings = match.MatchInnings.Where(i => i.BattingMatchTeamId == matchTeam.MatchTeamId);
            var bowlingInnings = match.MatchInnings.Where(i => i.BowlingMatchTeamId == matchTeam.MatchTeamId);

            return(battingInnings.SelectMany(i => i.PlayerInnings.Where(pi => !string.IsNullOrEmpty(pi.Batter.PlayerIdentityName)).Select(pi => pi.Batter))
                   .Union(bowlingInnings.SelectMany(i => i.PlayerInnings.Where(pi => pi.DismissedBy != null && !string.IsNullOrEmpty(pi.DismissedBy.PlayerIdentityName)).Select(pi => pi.DismissedBy)), comparer)
                   .Union(bowlingInnings.SelectMany(i => i.PlayerInnings.Where(pi => pi.Bowler != null && !string.IsNullOrEmpty(pi.Bowler.PlayerIdentityName)).Select(pi => pi.Bowler)), comparer)
                   .Union(bowlingInnings.SelectMany(i => i.OversBowled.Where(pi => !string.IsNullOrEmpty(pi.Bowler.PlayerIdentityName)).Select(pi => pi.Bowler)), comparer)
                   .Union(bowlingInnings.SelectMany(i => i.BowlingFigures.Where(pi => !string.IsNullOrEmpty(pi.Bowler.PlayerIdentityName)).Select(pi => pi.Bowler)), comparer)
                   .Union(match.Awards.Where(award => !string.IsNullOrEmpty(award.PlayerIdentity?.PlayerIdentityName) && award.PlayerIdentity.Team.TeamId == matchTeam.Team.TeamId).Select(x => x.PlayerIdentity)).Distinct(comparer));
        }
Beispiel #7
0
        public async Task SendNewTeamMemberNotice(Team team, User user, TeamRole role)
        {
            var viewbag = GetViewData();

            viewbag["Team"] = team;

            var model = new NewTeamMemberViewModel()
            {
                Team = team,
                User = user,
                Role = role
            };

            // add model data to email
            var prehtml = await RazorTemplateEngine.RenderAsync("/Views/NewTeamMember.cshtml", model, viewbag);

            // convert email to real html
            MjmlResponse mjml = await _mjmlServices.Render(prehtml);

            // build email
            using (var message = new MailMessage {
                From = _fromAddress, Subject = "UC Davis Payments Invitation"
            })
            {
                message.Body       = mjml.Html;
                message.IsBodyHtml = true;
                message.To.Add(new MailAddress(user.Email, user.Name));

                // ship it
                await _client.SendMailAsync(message);

                Log.Information("Sent Email");
            }
        }
        public async Task <JsonResult> GetTicketsByTeam(int?teamId)
        {
            if (teamId != null)
            {
                Team curTeam = await db.Teams.Include(x => x.Tickets).SingleOrDefaultAsync(y => y.Id == teamId);

                if (curTeam != null)
                {
                    User curUser = await userManager.GetCurrentUser();

                    if (curTeam.Users.Find(x => x.Id == curUser.Id) != null || curUser.AppRole.Permissions.IsAdmin)
                    {
                        UserPermission curUserPerms = curTeam.UserPermissions.SingleOrDefault(x => x.User.Id == curUser.Id);
                        if ((curUser != null && curUserPerms != null) || (curUser != null && curUser.AppRole.Permissions.IsAdmin))
                        {
                            TeamRole curTeamUserRole = null;
                            if (curUserPerms != null)
                            {
                                curTeamUserRole = curUserPerms.TeamRole;
                            }
                            List <Ticket> curTickets = await ticketManager.GetTicketsByTeam(teamId);

                            List <TicketDTO> curTicketsDto = dtoConverter.ConvertTicketList(curTickets, curUser, curTeamUserRole.Permissions);
                            return(Json(curTicketsDto, JsonRequestBehavior.AllowGet));
                        }
                    }
                }
            }
            return(Json(null));
        }
Beispiel #9
0
 void Awake()
 {
     collider2D = gameObject.GetComponent <BoxCollider2D>();
     gameEngine = GameObject.Find("Game Manager").GetComponent <GameEngine>(); //Uncomment this
     owner      = gameObject.GetComponent <Block>().role;
     onCooldown = false;
 }
        public async Task <ActionResult> CreateTeamRole(TeamRole newTeamRole)
        {
            if (ModelState.IsValid)
            {
                User curUser = await userManager.GetCurrentUser();

                if (curUser.AppRole.Permissions.CanManageUserRoles == true || curUser.AppRole.Permissions.IsAdmin == true)
                {
                    if (await dbContext.TeamRoles.SingleOrDefaultAsync(x => x.Name.Equals(newTeamRole.Name)) == null)
                    {
                        dbContext.TeamRoles.Add(newTeamRole);
                        await dbContext.SaveChangesAsync();

                        return(Redirect("/Role/List"));
                    }
                    else
                    {
                        ModelState.AddModelError("NameExists", "Role with that name already exists.");
                    }
                }
                else
                {
                    return(RedirectToAction("NoPermissionError", "Ticket"));
                }
            }

            return(View());
        }
Beispiel #11
0
    /// <summary>
    /// Event when the "Join Role" is pressed for a particular GUI lobby slot.
    /// </summary>
    public void OnClick_JoinRole(string teamRole)
    {
        TeamRole dTeamRole = (TeamRole)Enum.Parse(typeof(TeamRole), teamRole);

        LobbySlot myCurSlot = GetMyLobbySlot();

        if (myCurSlot != null)
        {
            UnoccupyLobbySlot(myCurSlot.teamRole);
        }

        // As host, let everyone know about my change.
        if (mIsHost)
        {
            OccupyLobbySlot(dTeamRole, mUsername, mIsHost, true);
            LobbyStatePacket lobbyState = CopyLobbyStateToPacket();
            mLobby.SendNewTrueLobbyState(lobbyState);
        }
        // As client, inform server.
        else
        {
            LobbyUpdateFromClientPacket sendPkt = new LobbyUpdateFromClientPacket();
//			sendPkt.IsReady = false;
            sendPkt.IsOccupied = true;
            sendPkt.TeamRole   = dTeamRole;
            sendPkt.Username   = mUsername;
            mLobby.SendLobbyUpdateFromClient(sendPkt);
        }
    }
Beispiel #12
0
 public Team()
 {
     Name         = "";
     Secret       = "";
     Authenticate = true;
     Role         = TeamRole.Normal;
 }
Beispiel #13
0
 public PlayerSetRoleEvent(Player player, TeamRole teamRole, RoleType role, List <ItemType> items, bool usingDefaultItem = true) : base(player)
 {
     TeamRole         = teamRole;
     Role             = role;
     Items            = items;
     UsingDefaultItem = usingDefaultItem;
 }
Beispiel #14
0
        /// <summary>
        /// 查询指定角色名的角色
        /// </summary>
        /// <param name="Public"></param>
        /// <param name="RoleName"></param>
        /// <returns></returns>
        public static TeamRole[] GetRoleByName(this Public Public, string RoleName)
        {
            TeamRole factor = new TeamRole(string.Empty, RoleName);
            EntityQueryRequest <TeamRole> query = new EntityQueryRequest <TeamRole>();

            query.AppendConditionMap(factor.Name, () => factor.Name);
            return(Actor.Public.BuildEntityProcessor("SecurityApp").QueryEntity(query));
        }
Beispiel #15
0
        public static TeamRole GetRole(this Public Public, string RoleID)
        {
            TeamRole factor = new TeamRole(RoleID, string.Empty);
            EntityQueryRequest <TeamRole> query = new EntityQueryRequest <TeamRole>();

            query.AppendConditionMap(factor.ID, () => factor.ID);
            return(Actor.Public.BuildEntityProcessor("SecurityApp").QueryEntity(query).FirstOrDefault());
        }
Beispiel #16
0
        /// <summary>
        /// 角色实体数据映射
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        public static TeamRole Role_Map(DataReader reader)
        {
            TeamRole role = new TeamRole(reader.GetString("RoleID"), reader.GetStringNullable("RoleName"))
            {
                RoleDescription = reader.GetString("Description")
            };

            return(role);
        }
Beispiel #17
0
        /// <summary>
        /// Оповестить об изменении количества членов команды.
        /// </summary>
        /// <param name="role">Принадлежность к команде.</param>
        /// <param name="count">Количество игроков.</param>
        public void FireTeamCountChanged(TeamRole role, ushort count)
        {
            var data = new byte[3];

            data[0] = (byte)role;
            BitConverter.GetBytes(count).CopyTo(data, 1);
            FireInformationReport(
                new NmsInformationReport(Address.Empty, (int)GameReports.TeamCount, NmsValueType.UInt8Array, data));
        }
 public BlockUpdatePacket(Vector3 pos, string t, bool bwa)
 {
     position      = pos;
     type          = t;
     activated     = false;
     isTrap        = false;
     blockWasAdded = bwa;
     role          = TeamRole.PurpleBuilder;
 }
Beispiel #19
0
        public ICustomClass GetRotationByTeamRole(TeamRole teamRole)
        {
            switch (teamRole)
            {
            case TeamRole.Tank: return(new WarriorTank(5));

            case TeamRole.Dps: return(new WarriorDPS(5));
            }
            return(new WarriorDPS(5));
        }
Beispiel #20
0
        public async Task <ActionResult> CreateTeamRole(TeamRole newTeamRole)
        {
            if (ModelState.IsValid)
            {
                dbContext.TeamRoles.Add(newTeamRole);
                await dbContext.SaveChangesAsync();
            }

            return(View());
        }
Beispiel #21
0
 public GameStartMsg(PlayerGuid playerGuid, TeamColor team, TeamRole teamRole, int teamSize,
                     string[] teamGuids, GameMaster.Positions.Position position, GameMaster.Boards.Board board) : base(playerGuid, "start")
 {
     this.team      = team;
     this.teamRole  = teamRole;
     this.teamSize  = teamSize;
     this.teamGuids = teamGuids;
     this.position  = position;
     this.board     = board;
 }
Beispiel #22
0
 public static Role GetRole(TeamRole teamRole)
 {
     if (teamRole == TeamRole.PurpleRunner || teamRole == TeamRole.YellowRunner)
     {
         return(Role.Runner);
     }
     else
     {
         return(Role.Builder);
     }
 }
Beispiel #23
0
        public IHttpActionResult GetTeamRole(string id)
        {
            TeamRole teamRole = db.TeamRoles.Find(id);

            if (teamRole == null)
            {
                return(NotFound());
            }

            return(Ok(teamRole));
        }
Beispiel #24
0
 public void Enlist(Hero hero, TeamRole role)
 {
     if (this.TeamSlots.ContainsKey(role) && this.TeamSlots[role] is null)
     {
         throw new TeamRoleTakenException(new TeamRoleTakenExceptionArgs(role, hero));
     }
     else
     {
         this.TeamSlots.Add(role, hero);
     }
 }
Beispiel #25
0
    /* Handle game over / scoreboard display */

    /// <summary>
    /// Invoked by GameOver() in GameEngine.cs.
    /// </summary>
    public void ShowScoreboardMenu(ScoreboardStatePacket scorePacket, TeamRole myTeamRole)
    {
        foreach (ScoreboardSlot slot in mScoreboardSlots)
        {
            if (slot.teamRole == TeamRole.PurpleRunner)
            {
                slot.roleUsername.text = "Runner - " + scorePacket.PurpleRunner.Username;
                slot.summary.text      = "Flags Captured: " + scorePacket.PurpleRunner.FlagsCaptured + "\n";
                slot.summary.text     += "Deaths: " + scorePacket.PurpleRunner.Deaths;
            }
            else if (slot.teamRole == TeamRole.PurpleBuilder)
            {
                slot.roleUsername.text = "Builder - " + scorePacket.PurpleBuilder.Username;
                slot.summary.text      = "Blocks Placed: " + scorePacket.PurpleBuilder.BlocksPlaced + "\n";
            }
            else if (slot.teamRole == TeamRole.YellowRunner)
            {
                slot.roleUsername.text = "Runner - " + scorePacket.YellowRunner.Username;
                slot.summary.text      = "Flags Captured: " + scorePacket.YellowRunner.FlagsCaptured + "\n";
                slot.summary.text     += "Deaths: " + scorePacket.YellowRunner.Deaths;
            }
            else if (slot.teamRole == TeamRole.YellowBuilder)
            {
                slot.roleUsername.text = "Builder - " + scorePacket.YellowBuilder.Username;
                slot.summary.text      = "Blocks Placed: " + scorePacket.YellowBuilder.BlocksPlaced + "\n";
            }
        }

        mScoreboardMenu_purpleScoreText.text = scorePacket.PurpleRunner.FlagsCaptured.ToString();
        mScoreboardMenu_yellowScoreText.text = scorePacket.YellowRunner.FlagsCaptured.ToString();

        Team myTeam = Common.GetTeam(myTeamRole);

        bool isPurpleWin = (scorePacket.PurpleRunner.FlagsCaptured > scorePacket.YellowRunner.FlagsCaptured);
        bool isYellowWin = (scorePacket.YellowRunner.FlagsCaptured > scorePacket.PurpleRunner.FlagsCaptured);
        bool isTie       = (scorePacket.PurpleRunner.FlagsCaptured == scorePacket.YellowRunner.FlagsCaptured);

        if (isTie)
        {
            mScoreboardMenu_youWinLoseText.text = "Draw Game!";
        }
        else if (myTeam == Team.Purple && isPurpleWin || myTeam == Team.Yellow && isYellowWin)
        {
            mScoreboardMenu_youWinLoseText.text = "You Win!";
        }
        else
        {
            mScoreboardMenu_youWinLoseText.text = "You Lose!";
        }

        mScoreboardMenu_returnToLobbyBut.gameObject.SetActive(mIsHost);

        SwitchMenu(mScoreboardMenu);
    }
Beispiel #26
0
 public static Team GetTeam(TeamRole teamRole)
 {
     if (teamRole == TeamRole.PurpleRunner || teamRole == TeamRole.PurpleBuilder)
     {
         return(Team.Purple);
     }
     else
     {
         return(Team.Yellow);
     }
 }
Beispiel #27
0
        static EntityPostRequest BuilddeleteRoleRequest(string roleid)
        {
            TeamRole          role    = new TeamRole(roleid, string.Empty);
            EntityPostRequest request = new EntityPostRequest(EntityPostRequest.EntityPostMethod.Delete)
            {
                Entity = role
            };

            request.AppendConditionMap(role.ID, () => role.ID);
            return(request);
        }
Beispiel #28
0
 private void Start()
 {
     owner = gameObject.GetComponent <Block>().role;
     if (owner == TeamRole.PurpleBuilder) //0 for left team
     {
         transform.localScale = new Vector3(transform.localScale.x * 1, transform.localScale.y, transform.localScale.z);
     }
     else
     {
         transform.localScale = new Vector3(transform.localScale.x * -1, transform.localScale.y, transform.localScale.z);
     }
 }
Beispiel #29
0
        static RoleRepository()
        {
            TeamRole entity = new TeamRole(Guid.NewGuid().ToString(), string.Empty);
            Type     type   = entity.GetType();

            AppendDataMap(type, "RoleID", () => entity.ID);
            AppendDataMap(type, "RoleName", () => entity.Name);
            AppendDataMap(type, "Description", () => entity.RoleDescription);
            ResultMapDelegate <TeamRole> queryMap = Role_Map;

            QueryMapContainer[entity.GetType()] = queryMap;
        }
Beispiel #30
0
        bool IsChecked(TeamRole role, int key)
        {
            Bzure.Apps.Security.DroitResource
                       rs          = this.Model.DRList.FirstOrDefault(m => m.RoleID == role.ID);
            List <int> RightValues = new List <int>();

            if (rs.IsNotNull())
            {
                RightValues.AddRange(rs.RightValue.ToFlags());
            }
            return(rs.IsNotNull() && RightValues.Contains(key));
        }