use of fr.neamar.lolgamedata.pojo.Player in project teamward-client by Neamar.
the class Tracker method trackGameViewed.
static void trackGameViewed(Activity activity, Account account, Game game, String defaultTab, Boolean shouldDisplayChampionName, String source) {
JSONObject j = account.toJsonObject();
LolApplication application = getApplication(activity);
try {
j.putOpt("game_map_id", game.mapId);
j.putOpt("game_map_name", activity.getString(getMapName(game.mapId)));
j.putOpt("queue", game.queue);
j.putOpt("game_id", game.gameId);
j.putOpt("default_tab", defaultTab);
j.putOpt("display_champion_name", shouldDisplayChampionName);
j.putOpt("source", source);
// Is this the first account added to the app?
AccountManager accountManager = new AccountManager(activity);
int accountIndex = accountManager.getAccountIndex(account);
j.putOpt("account_index", accountIndex);
// Add metrics related to the current player
Player p = game.getPlayerByAccount(account);
if (p != null) {
j.putOpt("champion", p.champion.id);
j.putOpt("champion_name", p.champion.name);
j.putOpt("champion_mastery", p.champion.mastery);
j.putOpt("champion_role", p.champion.role);
j.putOpt("player_rank", p.rank.tier.isEmpty() ? p.rank.oldTier : p.rank.tier);
j.putOpt("player_level", p.summoner.level);
j.putOpt("player_champion_index", p.champion.championRank);
j.putOpt("spell_d", p.spellD.id);
j.putOpt("spell_d_name", p.spellD.name);
j.putOpt("spell_f", p.spellF.id);
j.putOpt("spell_f_name", p.spellF.name);
if (accountIndex == 0) {
// For main user: add data to profile
JSONObject jp = new JSONObject();
jp.put("player_rank", p.rank.tier.isEmpty() ? p.rank.oldTier : p.rank.tier);
jp.put("last_viewed_game", new Date());
trackProfile(activity, jp);
}
}
} catch (JSONException e) {
e.printStackTrace();
}
track(activity, "Game viewed", j);
Identify identify = new Identify().add("games_viewed_count", 1).set("last_viewed_game", new Date().toString());
Amplitude.getInstance().identify(identify);
}
use of fr.neamar.lolgamedata.pojo.Player in project teamward-client by Neamar.
the class TryHarderTipBuilder method getTips.
@Override
public ArrayList<Tip> getTips(Game game, Context context) {
ArrayList<Tip> tips = new ArrayList<>();
for (Team team : game.teams) {
int minMastery = 7;
for (Player player : team.players) {
minMastery = Math.min(player.champion.mastery, minMastery);
}
if (minMastery >= 4) {
String description = context.getString(R.string.try_harder_desc);
description = String.format(description, team.getName(context), minMastery);
tips.add(new PlayerStandardTip(game, null, PlayerHolder.CHAMPION_MASTERIES_RESOURCES[minMastery], context.getString(R.string.try_harder), description));
}
}
return tips;
}
use of fr.neamar.lolgamedata.pojo.Player in project teamward-client by Neamar.
the class PremadeTipHolder method drawChampions.
private void drawChampions(Team team) {
LinearLayout linearLayout = team.teamId == 100 ? blueTeamLayout : redTeamLayout;
int dpConversion = (int) itemView.getResources().getDimension(R.dimen.tip_premade_champion_thumbnail);
int spConversion = (int) itemView.getResources().getDimension(R.dimen.tip_premade_champion_text_separator);
// Clean up old views
linearLayout.removeAllViews();
for (List<Integer> subPremade : team.premades) {
for (int summonerId : subPremade) {
Player p = findPlayerById(team, summonerId);
if (p == null) {
continue;
}
ChampionInGame champion = p.champion;
ImageView imageview = new ImageView(itemView.getContext());
imageview.setImageResource(R.drawable.default_champion);
imageview.setLayoutParams(new LinearLayout.LayoutParams(dpConversion, dpConversion));
linearLayout.addView(imageview);
ImageLoader.getInstance().displayImage(champion.imageUrl, imageview);
imageview.setContentDescription(champion.name);
}
if (subPremade != team.premades.get(team.premades.size() - 1)) {
TextView textView = new TextView(itemView.getContext());
textView.setText("—");
textView.setGravity(Gravity.CENTER);
textView.setTextSize(spConversion);
linearLayout.addView(textView);
}
}
}
use of fr.neamar.lolgamedata.pojo.Player in project teamward-client by Neamar.
the class HardcoreGamerTipBuilder method getTips.
@Override
public ArrayList<Tip> getTips(Game game, Context context) {
ArrayList<Tip> tips = new ArrayList<>();
for (Team team : game.teams) {
for (Player player : team.players) {
if (player.averageTimeBetweenGames < 24 * 3600 / 10) {
String descriptionTemplate = context.getString(R.string.hardcore_gamer_description);
String description = String.format(descriptionTemplate, player.summoner.name);
tips.add(new PlayerStandardTip(game, player, player.champion.imageUrl, context.getString(R.string.hardcore_gamer), description));
}
}
}
return tips;
}
use of fr.neamar.lolgamedata.pojo.Player in project teamward-client by Neamar.
the class NoFlashTipBuilder method getTips.
@Override
public ArrayList<Tip> getTips(Game game, Context context) {
ArrayList<Tip> tips = new ArrayList<>();
for (Team team : game.teams) {
for (Player player : team.players) {
if (!player.spellD.name.equals("Flash") && !player.spellF.name.equals("Flash")) {
String descriptionTemplate = context.getString(R.string.s_has_no_flash);
String description = String.format(descriptionTemplate, player.summoner.name, player.spellD.name, player.spellF.name);
tips.add(new PlayerStandardTip(game, player, player.champion.imageUrl, context.getString(R.string.no_flash), description));
}
}
}
return tips;
}
Aggregations