Examples of Avatar


Examples of fr.ippon.tatami.domain.Avatar

    @ResponseBody
    @Timed
    public List<UploadedFile> uploadAvatar(
            @RequestParam("uploadFile") MultipartFile file) throws IOException {

        Avatar avatar = new Avatar();
        avatar.setContent(file.getBytes());
        avatar.setFilename(file.getOriginalFilename());
        avatar.setSize(file.getSize());
        avatar.setCreationDate(new Date());

        avatarService.createAvatar(avatar);

        List<UploadedFile> uploadedFiles = new ArrayList<UploadedFile>();
        UploadedFile uploadedFile = new UploadedFile(
                avatar.getAvatarId(),
                file.getOriginalFilename(),
                Long.valueOf(file.getSize()).intValue(),
                tatamiUrl + "/tatami/avatar/" + avatar.getAvatarId() + "/" + file.getOriginalFilename());

        log.info("Avatar url : {}/tatami/avatar/{}/{}", tatamiUrl, avatar.getAvatarId(), file.getOriginalFilename());

        uploadedFiles.add(uploadedFile);

        User user = authenticationService.getCurrentUser();
        user.setAvatar(avatar.getAvatarId());

        userRepository.updateUser(user);

        return uploadedFiles;
View Full Code Here

Examples of fr.ippon.tatami.domain.Avatar

    @ResponseBody
    @Timed
    public void uploadAvatarIE(
            @RequestParam("uploadFile") MultipartFile file) throws IOException {

        Avatar avatar = new Avatar();
        avatar.setContent(file.getBytes());
        avatar.setFilename(file.getOriginalFilename());
        avatar.setSize(file.getSize());
        avatar.setCreationDate(new Date());

        avatarService.createAvatar(avatar);

        log.info("Avatar url : {}/tatami/avatar/{}/{}", tatamiUrl, avatar.getAvatarId(), file.getOriginalFilename());

        User user = authenticationService.getCurrentUser();
        user.setAvatar(avatar.getAvatarId());

        userRepository.updateUser(user);

    }
View Full Code Here

Examples of model.Avatar

                    System.out.println("*****World start*****");
                    world.toString();
                    System.out.println("*****World end*****");

                    //Create an avatar for this user.
                    Avatar ava = new Avatar(-1);
                    ava.setPlayerID(client.getPlayer().getID());
                    //Set [team_no] & [envPosition] for this avatar.
                    ava.setTeamNo(sameEnv.getRow());

                    int avatar_id = AvatarDAO.createAvatar(ava);

                    ava.setPlayerID(client.getPlayer().getID());

                    client.setAvatar(ava);
                    client.setWorld(world);


View Full Code Here

Examples of model.Avatar

        return avatar_id;
    }

    public static Avatar getAvatar(int avatar_id) throws SQLException {
        Avatar avatar = null;

        String query = "SELECT * FROM `avatar` WHERE `avatar_id` = ?";

        Connection connection = null;
        PreparedStatement pstmt = null;

        try {
            connection = DAO.getDataSource().getConnection();
            pstmt = connection.prepareStatement(query);
            pstmt.setInt(1, avatar_id);
            ResultSet rs = pstmt.executeQuery();

            if (rs.next()) {
                avatar = new Avatar(rs.getInt("avatar_id"));
                avatar.setAvatarType(rs.getInt("type"));
                avatar.setExperience(rs.getInt("experience"));
                avatar.setAbilityPoints(rs.getInt("ability_points"));
                avatar.setCurrency(rs.getInt("currency"));
                avatar.setLevel(rs.getInt("level"));
                avatar.setGameScaleVote(rs.getInt("gamescale_vote"));
                avatar.setLastPlayed(rs.getString("last_played"));
            }

            rs.close();
            pstmt.close();
        } finally {
View Full Code Here

Examples of model.Avatar

            pstmt = connection.prepareStatement(query);
            pstmt.setInt(1, player_id);
            ResultSet rs = pstmt.executeQuery();

            while (rs.next()) {
                Avatar avatar = new Avatar(rs.getInt("avatar_id"));
                avatar.setAvatarType(rs.getInt("type"));
                avatar.setExperience(rs.getInt("experience"));
                avatar.setAbilityPoints(rs.getInt("ability_points"));
                avatar.setCurrency(rs.getInt("currency"));
                avatar.setLevel(rs.getInt("level"));
                avatar.setGameScaleVote(rs.getInt("gamescale_vote"));
                avatar.setLastPlayed(rs.getString("last_played"));

                avatars.add(avatar);
            }

            rs.close();
View Full Code Here

Examples of model.Avatar

        avatar_id = DataReader.readInt(dataInput);
    }

    @Override
    public void doBusiness() throws Exception {
        Avatar avatar = client.getAvatar();

        if (avatar != null) {
        } else {
//            avatar = AvatarDAO.getAvatar(avatar_id);
            avatar = AvatarDAO.getAvatars(client.getPlayer().getID()).get(0);
View Full Code Here

Examples of model.Avatar

     * @return Returns the first AvatarType which matches the passed argument,
     * avatarType, in the database.  If none found returns null.
     * @throws SQLException
     */
    public static Avatar getAvatarByAvatarTypeSpecialUse(String avatarType) throws SQLException {
        Avatar returnFirstAvatar = null;

        List<Avatar> holdAvatarList = new ArrayList<Avatar>();

        String query = "SELECT * FROM `avatar` WHERE `type` = ?";

        Connection connection = null;
        PreparedStatement pstmt = null;

        try {
            connection = DAO.getDataSource().getConnection();
            pstmt = connection.prepareStatement(query);
            pstmt.setString(1, avatarType);
            ResultSet rs = pstmt.executeQuery();

            while (rs.next()) {
                Avatar holdAvatar = new Avatar(rs.getInt("avatar_id"));
                holdAvatar.setAvatarType(rs.getInt("type"));
                holdAvatar.setExperience(rs.getInt("experience"));
                holdAvatar.setAbilityPoints(rs.getInt("ability_points"));
                holdAvatar.setCurrency(rs.getInt("currency"));
                holdAvatar.setPlayerID(rs.getInt("player_id"));
                holdAvatar.setLevel(rs.getInt("level"));
                holdAvatar.setGameScaleVote(rs.getInt("gamescale_vote"));
                holdAvatarList.add(holdAvatar);
            }

            rs.close();
            pstmt.close();
View Full Code Here

Examples of model.Avatar

            } else if (PlayerDAO.containsUsername(username)) {
                responseRegist.setStatus((short) 2);
            } else {
                int player_id = PlayerDAO.createAccount(email, password, username, first_name, last_name, client.getIP());
               
                Avatar avatar = new Avatar(-1);
                avatar.setAvatarType(1);
                avatar.setCurrency(Constants.INITIAL_GOLD);
                avatar.setPlayerID(player_id);
                AvatarDAO.createAvatar(avatar);
                responseRegist.setStatus((short) 0);
            }
        }
    }
View Full Code Here

Examples of model.Avatar

            }
        }
    }

    public void updateCash(Player player, int amount) {
        Avatar avatar = player.getAvatar();
        avatar.setCurrency(Math.min(Constants.MAX_GOLD, avatar.getCurrency() + amount));

        try {
            AvatarDAO.updateCurrency(avatar);
        } catch (SQLException ex) {
            System.err.println(ex.getMessage());
        }

        ResponseUpdateCash updateResponse = new ResponseUpdateCash();
        updateResponse.setAmount(amount);
        updateResponse.setCash(avatar.getCurrency());

        addResponseForUser(player.getID(), updateResponse);
    }
View Full Code Here

Examples of model.Avatar

    }

    public void updateExperience(Player player, int amount) {
        amount *= Constants.MULTIPLIER_EXP;

        Avatar avatar = player.getAvatar();
        avatar.setExperience(Math.min(ExpTable.getExp(Constants.MAX_LEVEL - 1), avatar.getExperience() + amount));

        try {
            AvatarDAO.updateExperience(avatar);
        } catch (SQLException ex) {
            System.err.println(ex.getMessage());
        }

        int oldLevel = avatar.getLevel(), newLevel = ExpTable.getLevel(avatar.getExperience());

        if (newLevel > oldLevel) {
            avatar.setLevel(newLevel);

            try {
                AvatarDAO.updateLevel(avatar);
            } catch (SQLException ex) {
                System.err.println(ex.getMessage());
            }

            ResponseUpdateLevel updateLevelResponse = new ResponseUpdateLevel();
            updateLevelResponse.setAmount(newLevel - oldLevel);
            updateLevelResponse.setLevel(newLevel);

            String range = String.valueOf(ExpTable.getExpToAdvance(oldLevel + 1));
            for (int i = oldLevel + 2; i <= newLevel; i++) {
                range += "," + ExpTable.getExpToAdvance(i);
            }
            updateLevelResponse.setRange(range);

            addResponseForUser(player.getID(), updateLevelResponse);

            updateCash(player, amount);

            List<SpeciesType> unlockList = new ArrayList<SpeciesType>();

            try {
                for (int i = oldLevel + 1; i <= newLevel; i++) {
                    unlockList.addAll(ShopDAO.getAnimalsByLevel(i));
                    unlockList.addAll(ShopDAO.getPlantsByLevel(i));
                }

                ResponseShopUnlock unlockResponse = new ResponseShopUnlock();
                unlockResponse.setUnlockList(unlockList);

                GameServer.getInstance().addResponseForUser(player.getID(), unlockResponse);
            } catch (SQLException ex) {
                System.err.println(ex.getMessage());
            }
        }

        ResponseUpdateXP updateResponse = new ResponseUpdateXP();
        updateResponse.setAmount(amount);
        updateResponse.setTotal(avatar.getExperience());

        addResponseForUser(player.getID(), updateResponse);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.