Examples of Hra


Examples of cz.beranek.model.Hra

   * @return
   */
  @RequestMapping(value="/konecTahu.do")
  public String konecTahu(Model model,@ModelAttribute("hraId") String hraId,@ModelAttribute("userId") String hracId){
    //System.out.println(hraId + " konec tahu.");
    Hra h = SpravceHer.getInstance().getHra(hraId);
    if(h.konecTahu(h.getHrac(hracId))){
      //ma pravo prehodit tah
      model.addAttribute("JSON", "{\"prepnuto\":true}");
    }else{
      //nema pravo prehodit tah
      model.addAttribute("JSON", "{\"pripraven\":false}");
View Full Code Here

Examples of cz.beranek.model.Hra

   * Pote poslat potvrzeni nebo zamitnuti.
   */
  @RequestMapping(value="/KupPole.do")
  public String kupPole(Model model,@ModelAttribute("userId") String userId,@ModelAttribute("hraId") String hraId){

    Hra hra = SpravceHer.getInstance().getHra(hraId);
    Hrac hrac = hra.getHraci().get(userId);
   
    HashMap<String, String> zprava = new HashMap<String, String>(8);
    zprava.put("typ", "koupePole");
   
    int res = hra.kupPole(hra.getHrac(userId));
    switch(res){
    case 0:
      // tady pak  pouzit odesliKoupiPole (nebo teda nakou metodu ktera to pouzije)
      zprava.put("vysledek", "true");
      zprava.put("hrac", Integer.toString(hra.getHraci().getPoradi(userId)));
      zprava.put("pole", Integer.toString(hrac.getPozice()+1));
      break;
    case 10:     
      zprava.put("vysledek", "false");
      zprava.put("text", HerniPlan.getPole(hrac.getPozice()) + " pat�� jin�mu hr��i.");
View Full Code Here

Examples of cz.beranek.model.Hra

   * Pote poslat potvrzeni nebo zamitnuti.
   */
  @RequestMapping(value="/kupDostih.do")
  public String kupDostih(Model model,@ModelAttribute("userId") String userId,@ModelAttribute("hraId") String hraId){

    Hra hra = SpravceHer.getInstance().getHra(hraId);   
    Hrac hrac = hra.getHrac(userId);
    int res = hra.kupDostihy(hrac, 1);
    //FIXME: kupDostihy. Spring ResourceBundle na text zprav...
    switch (res){
    case 0:
      Kun k = (Kun)HerniPlan.getPole(hrac.getPozice());
      int pd = hra.getObsazeniDostihu().getDostihy(k);
      Zpravy.odesliPocetDostihu(hra, hrac, pd, hrac.getPozice());
      // Zpravy.odesliVsemZpravu(this, k + " je nyn� obsazen " + newKd + " dostihy.");
      break;
    case 10:
      Zpravy.odesliHraciZpravu(hrac, "Dostihy sm� kupovat pouze majitel cel� st�je.");
View Full Code Here

Examples of cz.beranek.model.Hra

  /**
   * Metoda pro refresh
   */
  @RequestMapping(value="/refresh.do")
  public String refreshHry(Model model,@ModelAttribute("userId") String userId,@ModelAttribute("hraId") String hraId){
    Hra hr = SpravceHer.getInstance().getHra(hraId);
    Map<String, String> zprava = new HashMap<String, String>();
   
    //prace s majetkem
    HashMap<String, Integer> tmp= new HashMap<String, Integer>();
    Map<Integer, Hrac> majetek = hr.getSeznamMajetku().getVeskeryMajetek();
   
    for (Integer klic : majetek.keySet()) {
      tmp.put(Integer.toString(klic+1), hr.getHraci().getPoradi((majetek.get(klic))));
    }
   
    JSONObject json=JSONObject.fromObject(tmp);
    zprava.put("majetek", json.toString());
   
    //prace s dostihy
    tmp= new HashMap<String, Integer>();
    Map<Integer, Integer> dostihy = hr.getObsazeniDostihu().getVsechnyDostihy();
   
    for (Integer klic : dostihy.keySet()) {
      tmp.put(Integer.toString(klic+1), dostihy.get(klic));
    }
   
    JSONObject jsonDostihy=JSONObject.fromObject(tmp);
    zprava.put("dostihy", jsonDostihy.toString());
   
    //pozice hracu
    tmp= new HashMap<String, Integer>();
    for (Hrac hrac : hr.getHraci()) {
      tmp.put(Integer.toString(hr.getHraci().getPoradi(hrac.getUserId())), hrac.getPozice()+1);
    }
    JSONObject jsonPozice=JSONObject.fromObject(tmp);
    zprava.put("pozice", jsonPozice.toString());
    //hrac na tahu
    SeznamHracu sh= hr.getHraci();
    Zpravy.odesliHraceNaTahu(hr, sh.naTahu());
    //penize
    tmp= new HashMap<String, Integer>();
    for (Hrac hrac : hr.getHraci()) {
      tmp.put(hrac.getUserId(), hrac.getPenize());
    }
    JSONObject jsonPenize=JSONObject.fromObject(tmp);
    zprava.put("penize", jsonPenize.toString());
   
View Full Code Here

Examples of cz.beranek.model.Hra

    zprava.put("login",login);
    zprava.put("zprava",text);
   
    JSONObject json=JSONObject.fromObject(zprava);

    Hra tmp = SpravceHer.getInstance().getHra(hraId);
    if (tmp == null) {
      System.out.println("neexistujici hra");
      return "zprava";
    }
    System.out.println(json.toString());
    for (Hrac s : tmp.getHraci().values()) {
      channel.sendMessage(new ChannelMessage(s.getUserId(), json.toString()));
    }
    return "zprava";
  }
View Full Code Here

Examples of cz.beranek.model.Hra

  }
 
  public static void odesliHrace(String hraId, String login, String userId) {
   
    final ChannelService chanel = ChannelServiceFactory.getChannelService();
    Hra tmp = SpravceHer.getInstance().getHra(hraId);
   
    HashMap<String, String> zprava=new HashMap<String, String>();
   
    zprava.put("typ", "connect");
    zprava.put("login", login);
   
    JSONObject json=JSONObject.fromObject(zprava);

    for (Hrac s : tmp.getHraci().values()) {
      if (!userId.equals(s.getUserId()))
        chanel.sendMessage(new ChannelMessage(s.getUserId(), json.toString()));
    }
  }
View Full Code Here

Examples of cz.beranek.model.Hra

  public static void odesliSeznamHracu(String hraId, String userId) {
   
    System.out.println("odeslani seznamu hracu");
    final ChannelService chanel = ChannelServiceFactory.getChannelService();
    Hra tmp = SpravceHer.getInstance().getHra(hraId);
   
    for (Hrac s : tmp.getHraci().values()) {
     
      HashMap<String, String> zprava=new HashMap<String, String>();
      zprava.put("typ", "connect");
      zprava.put("login", s.getNick());
     
View Full Code Here

Examples of cz.beranek.model.Hra

    System.out.println(login);
   
    String token;
    Hrac zakladatel=new Hrac(userId,login);
   
    Hra hra= new Hra();
    hra.addHrac(userId,zakladatel );
    hra.setHost(zakladatel);
   
    //zatim je jako id hry login zakladatele
    //System.out.println(SpravceHer.getInstance().toString());
    SpravceHer.getInstance().pridejHru(login, hra);
   
View Full Code Here

Examples of cz.beranek.model.Hra

      model.addAttribute("link", userService.createLoginURL("/pripoj.se?hra=" + hraId));
      return "login";
    } else {
      if (userService != null) {
        userId = userService.getCurrentUser().getUserId();
        Hra hra = SpravceHer.getInstance().getHra(hraId);
        Hrac hrac = hra.getHrac(userId);
        System.out.println("Hrac "+hrac.getNick()+" is ready");
        hrac.setReady(true);
        model.addAttribute("JSON", "{\"pripraven\":true}");
      }
    }
View Full Code Here

Examples of cz.beranek.model.Hra

      model.addAttribute("link", userService.createLoginURL("/pripoj.se?hra=" + hraId));
      return "login";
    } else {
      if (userService != null) {
        userId = userService.getCurrentUser().getUserId();
        Hra hra = SpravceHer.getInstance().getHra(hraId);
        Hrac hrac = hra.getHrac(userId);
        hrac.setGameLoaded(true);
        model.addAttribute("JSON", "{\"hraNactena\":true}");
      }
    }
    return "JSON";
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.