Package ru.webcrafter.core.entities

Examples of ru.webcrafter.core.entities.ItemTemplate


    public static void main(String[] args) {
        ApplicationContext applicationContext = new FileSystemXmlApplicationContext("classpath:client.xml");
        WebCrafterService service = (WebCrafterService) applicationContext.getBean("rmiProxy");

        try {
            ItemTemplate wood = service.getItemTemplate("Wood");
            if (wood == null) {
                wood = new ItemTemplate("Wood");
                service.addItemTemplate(wood);
            }
            ItemTemplate fire = service.getItemTemplate("Fire");
            if (fire == null) {
                fire = new ItemTemplate("Fire");
                service.addItemTemplate(fire);
            }
            ItemTemplate coal = service.getItemTemplate("Coal");
            if (coal == null) {
                coal = new ItemTemplate("Coal");
                service.addItemTemplate(coal);
            }
            Recipe makeWoodCoal = service.getRecipe("Coal");
            if (makeWoodCoal == null) {
                List<ItemTemplate> ingredients = new ArrayList<ItemTemplate>();
View Full Code Here


        service = (WebCrafterService) applicationContext.getBean("rmiProxy");
    }

    @RequestMapping("/admin")
    public String onAdminPageLoaded(Map<String, Object> map) {
        map.put("newItemTemplate", new ItemTemplate());
        map.put("newRecipe", new Recipe());

        map.put("itemTemplateList", service.getAllItemTemplates());
        map.put("recipeList", service.getAllRecipes());
View Full Code Here

                    break;
                }
            }
        }
        List<User> users = userDAO.getAllUsers();
        ItemTemplate itemTemplate = getItemTemplate(id);
        for (User user : users) {
            Map<String, Long> items = user.getItems();
            if (items.containsKey(itemTemplate.getId())) {
                items.remove(itemTemplate.getId());
            }
            user.setItems(items);
            updateUser(user);
        }
        itemTemplateDAO.deleteItemTemplate(id);
View Full Code Here

        int itemTemplatesCount = itemTemplates.size();
        Map<String, Long> items = new HashMap<String, Long>();
        if (itemTemplatesCount != 0) {
           for (int i = 0; i < itemsCount; ++i) {
               int idxItem = rnd.nextInt(itemTemplatesCount);
               ItemTemplate itemTpl = itemTemplates.get(idxItem);
               if (items.containsKey(itemTpl.getId())) {
                   items.put(itemTpl.getId(), items.get(itemTpl.getId()) + 1);
               } else {
                   items.put(itemTpl.getId(), 1L);
               }
           }
        }
        user.setItems(items);
    }
View Full Code Here

                items.remove(ingr.getId());
            } else {
                items.put(ingr.getId(), cnt);
            }
        }
        ItemTemplate res = recipe.getResult();
        if (items.containsKey(res.getId())) {
            items.put(res.getId(), items.get(res.getId()) + 1);
        } else {
            items.put(res.getId(), 1L);
        }
        user.setItems(items);

        updateUser(user);
View Full Code Here

    }

    public void userBuyItem(long id, String itemId) {
        User user = getUser(id);
        ItemTemplate itemTemplate = getItemTemplate(itemId);

        Long amount = user.getAmount();
        if (amount < itemTemplate.getCost()) {
            return;
        }
        user.setAmount(amount - itemTemplate.getCost());
        Map<String, Long> items = user.getItems();
        if (items.containsKey(itemId)) {
            items.put(itemId, items.get(itemId) + 1);
        } else {
            items.put(itemId, 1L);
View Full Code Here

            items.remove(itemId);
        } else {
            items.put(itemId, cnt);
        }
        user.setItems(items);
        ItemTemplate itemTemplate = getItemTemplate(itemId);
        user.setAmount(user.getAmount() + itemTemplate.getCost());

        updateUser(user);

    }
View Full Code Here

TOP

Related Classes of ru.webcrafter.core.entities.ItemTemplate

Copyright © 2018 www.massapicom. 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.