Exemple #1
0
        public double GetCalculatedPremium(UserDetails userDetails)
        {
            string rating = OccupationData.GetOccupationRating(userDetails.Occupation);
            double factor = OccupationData.GetRatingFactor(rating);
            int    age    = DateTime.Now.Year - userDetails.DoB.Year;

            return((userDetails.SumInsured * factor * age) / (1000 * 12));
        }
        public ActionResult Edit(int id, int OccupationType)
        {
            var Occupation = new Occupation();

            TryUpdateModel(Occupation);
            var constituentId =  Convert.ToInt32(Session["constituentId"]);
            Occupation.Type = new OccupationType {Id = OccupationType};
            Occupation.Address = new Address() {Id = 1};
            Occupation.Constituent = new Constituent {Id = constituentId};
            mapper = new AutoDataContractMapper();
            var OccupationData = new OccupationData();
            mapper.Map(Occupation, OccupationData);

            HttpHelper.Put(string.Format(serviceBaseUri+"/Occupations/{0}",id), OccupationData);
            return PartialView(new GridModel(GetOccupations()));
        }
    private void UpdateView()
    {
        var            data      = calculator.GetOccupationData();
        OccupationData totalData = new OccupationData();

        for (int i = 0; i < data.Count; i++)
        {
            viewItems[i].UpdateView(data[i]);

            totalData.HackedCount += data[i].HackedCount;
            totalData.TotalCount  += data[i].TotalCount;
        }

        totalData.PercentageControl += systemElementList.PercentageOccupation(virus.Value);
        totalItem.UpdateView(totalData);
    }
    public OccupationCalculator(SystemElementList systemElementList, VirusValue virus)
    {
        this.systemElementList = systemElementList;
        this.virus             = virus;

        var controlSizes = systemElementList.ControlElementSizes;

        occupationDataList = new List <OccupationData>(controlSizes.Count);
        foreach (var control in controlSizes)
        {
            var occupationData = new OccupationData()
            {
                Control = control.Key
            };
            occupationDataList.Add(occupationData);
        }
    }
Exemple #5
0
    public OccupationData getOccupation(String Occupation_Code)
    {
        OccupationData Occupation_data = new OccupationData();

        ConnectDB     db        = new ConnectDB();
        SqlDataSource oracleObj = db.ConnectionOracle();

        oracleObj.SelectCommand = "Select * From OCCUPATION Where OCCUPATION_CODE='" + Occupation_Code + "'";
        DataView allData = (DataView)oracleObj.Select(DataSourceSelectArguments.Empty);

        foreach (DataRowView rowData in allData)
        {
            Occupation_data.Occupation_Code = rowData["OCCUPATION_CODE"].ToString();
            Occupation_data.Occupation_Thai = rowData["OCCUPATION_THAI"].ToString();
            Occupation_data.Occupation_Eng  = rowData["OCCUPATION_ENG"].ToString();
        }

        return(Occupation_data);
    }
Exemple #6
0
    public void UpdateView(OccupationData occupationData)
    {
        if (occupationData.Control != null)
        {
            territoryNameText.text = occupationData.Control.Name;
        }

        string percentageOccupation = GetPercentageText(occupationData.PercentageControl);

        elementCountsText.text = string.Format("{0} / {1} ({2})", occupationData.HackedCount, occupationData.TotalCount, percentageOccupation);

        if (occupationData.Control != null)
        {
            string discount = GetPercentageText(occupationData.Control.OccupationDiscount);
            discountText.text = discount;

            territoryImage.sprite = occupationData.Control.Sprite;
        }
    }
Exemple #7
0
    public List <OccupationData> getOccupation()
    {
        List <OccupationData> Occupation_data = new List <OccupationData>();

        ConnectDB     db        = new ConnectDB();
        SqlDataSource oracleObj = db.ConnectionOracle();

        oracleObj.SelectCommand = "Select * From OCCUPATION Order By OCCUPATION_CODE";
        DataView allData = (DataView)oracleObj.Select(DataSourceSelectArguments.Empty);

        foreach (DataRowView rowData in allData)
        {
            OccupationData Occupation = new OccupationData();
            Occupation.Occupation_Code = rowData["OCCUPATION_CODE"].ToString();
            Occupation.Occupation_Thai = rowData["OCCUPATION_THAI"].ToString();
            Occupation.Occupation_Eng  = rowData["OCCUPATION_ENG"].ToString();
            Occupation_data.Add(Occupation);
        }

        return(Occupation_data);
    }
 /// <summary>
 /// 建構元
 /// </summary>
 /// <param name="content"></param>
 public ExperimentGroup(PM.ExperimentControl content)
 {
     Experiment = new OccupationData().Get((IPublishedContent)content.ExperimentItem);
    
 }
Exemple #9
0
    /// <summary>
    /// AdvancePiece manages the advancement of a single Piece selected by the player.
    /// This Piece can only move to the expected Tile if that Tile is either unoccupied
    /// or occupied by the opponents Piece that is on a non-rosette Tile (safe Tile).
    /// If there is an opponents Piece on the expected Tile, then bump it off and let
    /// this Piece occupy that Tile
    /// </summary>
    /// <param name="piece">The Piece selected by the player</param>
    /// <param name="moves">The amount of moves for this Piece</param>
    public void AdvancePiece(Piece piece, int moves, out bool landedOnRosette, out bool reselect)
    {
        Queue <Tile> path        = new Queue <Tile>();
        Tile         destination = null;
        bool         scored      = false;

        landedOnRosette = false;
        reselect        = false;


        // For whatever reason, if moves is less than or equal to 0,
        // don't allow this Piece to advance.
        // This should already be checked in the GameManager
        if (moves <= 0)
        {
            return;
        }

        // If the player selected a Piece that has already scored,
        // just make them reselect a different Piece
        if (piece.Scored)
        {
            reselect = true;
            return;
        }

        // If this Piece is not on the board
        if (!pieceManager.IsOnBoard(piece))
        {
            destination = tiles[moves - 1];

            // Build the path
            for (int i = 0; i <= IndexOf(destination); i++)
            {
                path.Enqueue(tiles[i]);
            }
        }
        // If this Piece is already on the board, then
        // get the destination Tile by getting this Piece's current Tile
        // and adding the number of times it will move forward. Now use this value as an
        // index for accessing the correct Tile within the tiles array
        else
        {
            int destIndex = IndexOf(pieceManager.GetTile(piece)) + moves;

            // SCORING MOVE - Player has exact amount of moves to score
            if (destIndex == TRACK_SIZE)
            {
                Debug.Log("Score a point!");
                piece.Scored = true;
                scored       = true;

                // Make destination equal to the last Tile on the board,
                // then enqueue the final destination (the scoring spot),
                // ONLY if moves is greater than 1, otherwise just enqueue
                // the last spot (finalDestination)
                if (moves > 1)
                {
                    destination = tiles[tiles.Length - 1];

                    // Build the path
                    int currentIndex = IndexOf(pieceManager.GetTile(piece)) + 1;
                    for (int i = currentIndex; i <= IndexOf(destination); i++)
                    {
                        path.Enqueue(tiles[i]);
                    }
                }

                destination = finalDestinationTile;
                path.Enqueue(finalDestinationTile);

                gameManager.ScorePoint(owner);
            }
            // More than exact amount of moves to score
            else if (destIndex > TRACK_SIZE)
            {
                Debug.Log("Can only score with exact move value. Went over scoring move.");
                reselect = true;
                return;
            }
            // Somewhere on the board
            else
            {
                destination = tiles[destIndex];

                // Build the path
                int currentIndex = IndexOf(pieceManager.GetTile(piece)) + 1;
                for (int i = currentIndex; i <= IndexOf(destination); i++)
                {
                    path.Enqueue(tiles[i]);
                }
            }
        }

        // DESTINATION TILE OBTAINED
        // Now we can get the OccupationData on this Tile to determine our next step in the process
        OccupationData occupationData = destination.GetOccupationData(owner, piece.GetPieceID());
        int            occupantId     = occupationData.PieceId;
        Track          opponentTrack  = null;

        // If the Tile is already occupied
        if (occupationData.IsOccupied)
        {
            // If an opponent's Piece occupies this Tile
            if (occupationData.OpponentOverlap && !destination.IsRosette)
            {
                // Bump the opponent's Piece
                opponentTrack = gameManager.GetOpponentTrack(owner);
                gameManager.SetOpponentTrack(opponentTrack);
                destination.Unoccupy();
            }
            // Otherwise this Tile is occupied by our own Piece or
            // destinationTile is a rosette and the opponent's Piece is safe
            else
            {
                reselect = true;
                return;
            }
        }

        // TIME TO MOVE
        // Now update occupationData after bumping the opponet's Piece and move in
        bool occupationSuccess = false;

        occupationData = destination.Occupy((int)owner, piece.GetPieceID(), out occupationSuccess);

        // At this point, destinationTile should be clear for this Piece to occupy.
        if (occupationSuccess)
        {
            // Move this Piece object to the destination Tile object
            gameManager.MoveQueue(piece, path, occupantId, scored);

            // Set piece's parent to destinationTile
            piece.transform.SetParent(destination.GetTileTransform().FindChild("Graphic"));

            // Unoccupy the old Tile
            if (pieceManager.IsOnBoard(piece))
            {
                pieceManager.GetTile(piece).Unoccupy();
            }

            // Occupy the new Tile
            if (destination != finalDestinationTile)
            {
                pieceManager.SetTile(piece, destination);
            }
            else
            {
                finalDestinationTile.Unoccupy();
            }

            landedOnRosette = destination.IsRosette;
        }
        else
        {
            // If this side of the if is called, then that means
            // destinationTile is still occupied by an opponent's piece,
            // when it shouldn't be...
            Debug.LogError("Something went wrong.");
        }
    }
Exemple #10
0
 public List <string> GetOccupationList()
 {
     return(OccupationData.GetOccupationList().Select(x => x.Occupation).ToList());
 }