Beispiel #1
0
    // MARK: Fetch

    public void fetchObjectives(Objectives.ObjectiveSet set, int numberOfObjectives = 3)
    {
        var request = new Objectives.FetchRequest();

        request.set = set;
        request.numberOfObjectives = numberOfObjectives;
        interactor.doFetch(request);
    }
    //--- WORLDS SET
    //TODO

    // MARK: - Private Methods

    private void buildFetchRequest(int number, Objectives.ObjectiveSet set)
    {
        var request = new Objectives.FetchRequest();

        request.numberOfObjectives = number;
        request.set = set;
        sut.doFetch(request);

        Assert.IsTrue(spy.presentFetchCalled);
        Assert.AreEqual(spy.lastFetchResponse.objectives.Length, request.numberOfObjectives);
    }
Beispiel #3
0
    // MARK: Fetch

    public void doFetch(Objectives.FetchRequest request)
    {
        var response = new Objectives.FetchResponse();

        numberOfObjectives = request.numberOfObjectives;
        fetchedSet         = request.set;

        this.fetchedObjectives = ObjectivesWorker.Read(numberOfObjectives, fetchedSet);
        response.objectives    = this.fetchedObjectives;
        response.currentIndex  = ObjectivesWorker.ReadIndex(fetchedSet);

        this.presenter.presentFetch(response);
    }
Beispiel #4
0
    public static void UpdateStatus(int id, Objectives.ObjectiveSet set, bool newValue)
    {
        var objectivesClaimAccessor = new _lvStatusAccessor();

        switch (set)
        {
        case Objectives.ObjectiveSet.Game:
            //game objectives begin at index 0
            var computedIndex = _gameObjectivesIndex + id;
            objectivesClaimAccessor[0, computedIndex + 1] = newValue ? 1 : 0;
            break;

        default:
            //worlds objectives begin at index 100
            int level = (int)set;
            objectivesClaimAccessor[level, id + 1] = newValue ? 1 : 0;
            break;
        }
    }
Beispiel #5
0
    public static Objectives.ObjectivesModel[] Read(int nb, Objectives.ObjectiveSet set)
    {
        var objectives = new List <Objectives.ObjectivesModel>();
        var objective  = new Objectives.ObjectivesModel();

        //==== STEP 1: Build raw Objectives
        if (nb == 0)
        {
            return(objectives.ToArray());
        }

        switch (set)
        {
        //----- GAME -----
        case Objectives.ObjectiveSet.Game:
            //game objectives begin at index 0
            objective.id            = 0;
            objective.currentStep   = 0;
            objective.numberOfSteps = 10;
            objective.title         = "Hit the Yellow Buzzer";
            objective.description   = "10 times !";
            objective.reward        = 100;
            objective.type          = Objectives.ObjectiveTypes.Yellow;
            objective.isLocal       = true;
            objectives.Add(objective);

            objective.id            = 1;
            objective.currentStep   = 0;
            objective.numberOfSteps = 10;
            objective.title         = "Hit the Green Buzzer";
            objective.description   = "10 times !";
            objective.reward        = 200;
            objective.type          = Objectives.ObjectiveTypes.Green;
            objective.isLocal       = true;
            objectives.Add(objective);

            objective.id            = 2;
            objective.currentStep   = 0;
            objective.numberOfSteps = 10;
            objective.title         = "Hit the Blue Buzzer";
            objective.description   = "10 times !";
            objective.reward        = 300;
            objective.type          = Objectives.ObjectiveTypes.Blue;
            objective.isLocal       = true;
            objectives.Add(objective);

            objective.id            = 3;
            objective.currentStep   = 0;
            objective.numberOfSteps = 2;
            objective.title         = "Hit the Yellow Buzzer";
            objective.description   = "20 times !";
            objective.reward        = 400;
            objective.type          = Objectives.ObjectiveTypes.Yellow;
            objective.isLocal       = true;
            objectives.Add(objective);

            objective.id            = 4;
            objective.currentStep   = 0;
            objective.numberOfSteps = 2;
            objective.title         = "Hit the Green Buzzer";
            objective.description   = "20 times !";
            objective.reward        = 500;
            objective.type          = Objectives.ObjectiveTypes.Green;
            objective.isLocal       = true;
            objectives.Add(objective);

            objective.id            = 5;
            objective.currentStep   = 0;
            objective.numberOfSteps = 2;
            objective.title         = "Hit the Blue Buzzer";
            objective.description   = "20 times !";
            objective.reward        = 600;
            objective.type          = Objectives.ObjectiveTypes.Blue;
            objective.isLocal       = true;
            objectives.Add(objective);

            GAME_OBJECTIVES_COUNT = objectives.Count;
            break;

        default:
            return(new Objectives.ObjectivesModel[] { });
        }

        //==== STEP 2: Update indexed Objectives with stored progress
        var objectivesProgressAccessor = new _lvObjAccessor();
        var objectivesClaimAccessor    = new _lvStatusAccessor();

        if (set == Objectives.ObjectiveSet.Game)
        {
            for (int i = 0; i < objectives.Count; i++)
            {
                var obj = objectives[i];
                obj.currentStep     = objectivesProgressAccessor[0, (i + 1)];
                obj.isRewardClaimed = objectivesClaimAccessor[0, (i + 1)] == 1 ? true : false;
                objectives[i]       = obj;
            }
        }
        else
        {
            for (int i = 0; i < objectives.Count; i++)
            {
                var obj = objectives[i];
                obj.currentStep     = objectivesProgressAccessor[(int)set, (i + 1)];
                obj.isRewardClaimed = objectivesClaimAccessor[(int)set, (i + 1)] == 1 ? true : false;
                objectives[i]       = obj;
            }
        }

        //==== STEP 3: Select at correct index if we are indexing game wide objectives
        var indexedObjectiveSet = (set == Objectives.ObjectiveSet.Game) ? objectives.ToArray().Skip(_gameObjectivesIndex).Take(nb).ToArray()
                                                                        : objectives.ToArray().Take(nb).ToArray();

        return(indexedObjectiveSet);
    }
Beispiel #6
0
    // MARK: Public Interface

    public static int ReadIndex(Objectives.ObjectiveSet set)
    {
        return((set == Objectives.ObjectiveSet.Game) ? _gameObjectivesIndex : 0);
    }