com.tera.gsaion.itest.model.playerbasic.PlayerCommonDataCreateUnit.java Source code

Java tutorial

Introduction

Here is the source code for com.tera.gsaion.itest.model.playerbasic.PlayerCommonDataCreateUnit.java

Source

/**
 * This file is part of tera-api.
 *
 * tera-api is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
    
 * tera-api is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
    
 * You should have received a copy of the GNU General Public License
 * along with tera-api.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.tera.gsaion.itest.model.playerbasic;

import javax.inject.Inject;

import org.apache.commons.lang.RandomStringUtils;

import com.tera.common.util.Rnd;
import com.tera.gapi.itest.model.FunctionalUnit;
import com.tera.gapi.player.model.PlayerClass;
import com.tera.gapi.player.model.PlayerCommonData;
import com.tera.gapi.player.model.PlayerGender;
import com.tera.gapi.player.model.PlayerRace;
import com.tera.gapi.player.service.PlayerCreationService;
import com.tera.gsaion.player.model.AionPlayerClass;
import com.tera.gsaion.player.model.AionPlayerRace;

/**
 * @author ATracer
 * @since 0.1.0
 */
public class PlayerCommonDataCreateUnit implements FunctionalUnit {

    public static final String UNIT_ID = "PLBAS-CREATE-COMDATA";

    @Inject
    private PlayerCreationService playerCreationService;

    public PlayerCommonData createNewCommonData(int accountId, String name, PlayerGender gender, PlayerRace race,
            PlayerClass playerClass) {
        return playerCreationService.buildCommonData(accountId, name, gender, race, playerClass);
    }

    public PlayerCommonData createRandomCommonData(int accountId) {
        PlayerRace race = Rnd.nextBoolean() ? AionPlayerRace.ELYOS : AionPlayerRace.ASMODIANS;
        return createRandomCommonData(accountId, race);
    }

    public PlayerCommonData createRandomCommonData(int accountId, PlayerRace race) {
        String name = RandomStringUtils.randomAlphabetic(10);
        PlayerGender gender = Rnd.nextBoolean() ? PlayerGender.MALE : PlayerGender.FEMALE;
        PlayerClass playerClass = Rnd.nextBoolean() ? AionPlayerClass.MAGE : AionPlayerClass.SCOUT;
        return createNewCommonData(accountId, name, gender, race, playerClass);
    }

    @Override
    public String getUnitId() {
        return UNIT_ID;
    }

}