public void setUgLink(GameData g) { // ug形式の短縮リンク変換 String t = g.getContents(); String regex = "ug[0-9]*"; Pattern p = Pattern.compile(regex); Matcher m = p.matcher(t); List<String> list = new ArrayList<String>(); while (m.find()) { list.add(m.group()); } for (String st : list) { // ugの後が数字でないものはリンク化行わない if (!st.matches("ug[^0-9]*")) { // ugを無くしてidだけを抽出 例)ug1234 → 1234 String ug = st.replaceAll("ug", ""); String s = t.replaceAll( st, "<a href='http://unity-games.appspot.com/" + "unitygames/game/ug" + ug + "'class='ugLink'>" + st + "</a>"); // 繰り返し置換していく t = s; } } g.setContents(t); }
public String connectFixTags(GameData g) { StringBuilder buf = new StringBuilder(); for (Tag t : g.getFixTags()) { buf.insert(0, t.getName() + ","); } if (buf.length() > 0) { buf.deleteCharAt(buf.length() - 1); } return buf.toString(); }
public List<GameData> contentCut(List<GameData> gameList) { for (GameData game : gameList) { if (game.getContents().length() >= 80) { String s = game.getContents().substring(0, 80); game.setContents(s + "..."); } if (game.getOperations().length() >= 80) { String o = game.getOperations().substring(0, 80); game.setOperations(o + "..."); } } return gameList; }
public List<EveryDayGameRankingVo> rankingGame(int maxNum) { List<EveryDayGameRanking> asList = Datastore.query(EveryDayGameRanking.class) .sort(EveryDayGameRankingMeta.get().deltaPoint.desc) .asList(); int size = asList.size(); if (size < maxNum) maxNum = size; List<EveryDayGameRankingVo> g = new ArrayList<EveryDayGameRankingVo>(); for (EveryDayGameRanking edg : asList) { GameData gameData = Datastore.get(GameData.class, edg.getKey().getParent()); contentCut(gameData); if (g.size() < maxNum) { EveryDayGameRankingVo setEdgvo = null; Set<Tag> fixTags = gameData.getFixTags(); int deltaPoit = edg.getDeltaPoint(); Boolean check = false; if (fixTags.size() != 0) { for (Tag tag : fixTags) { if (tag.getName().equals("チュートリアル")) { check = true; } } if (!check) { setEdgvo = setEdgvo(gameData, deltaPoit); g.add(setEdgvo); } } else { setEdgvo = setEdgvo(gameData, deltaPoit); g.add(setEdgvo); } } else break; } return g; }
public GameData contentCut(GameData game) { if (game.getContents().length() >= 80) { String s = game.getContents().substring(0, 80); game.setContents(s + "..."); } if (game.getOperations().length() >= 80) { String o = game.getOperations().substring(0, 80); game.setOperations(o + "..."); } return game; }
public void addAccessPoint(GameData g) { g.setAccess(g.getAccess() + 1); save(g); }
public void addPoint(GameData g) { int point = g.getAccess() + g.getComment() * 3; g.setPoint(point); save(g); }
public void setCode(GameData g, String commentary) { g.setCode(commentary); save(g); }
public void addTag(GameData g, Tag t) { g.getTags().add(t); save(g); }
public void createTags(GameData g) { g.setTags(new HashSet<Tag>()); save(g); }
public void deleteTagGame(GameData g, Tag t) { g.getTags().remove(t); save(g); }