Optimisations graphiques
This commit is contained in:
		@@ -1,5 +1,6 @@
 | 
			
		||||
package fr.ynerant.tarot;
 | 
			
		||||
 | 
			
		||||
import android.annotation.SuppressLint;
 | 
			
		||||
import android.preference.PreferenceManager;
 | 
			
		||||
import android.util.SparseArray;
 | 
			
		||||
 | 
			
		||||
@@ -32,20 +33,26 @@ public class Game {
 | 
			
		||||
	private int id;
 | 
			
		||||
	private Date date;
 | 
			
		||||
	private GameType gameType;
 | 
			
		||||
	@SuppressWarnings("unused")
 | 
			
		||||
	private Player player1, player2, player3, player4, player5, player6;
 | 
			
		||||
	private List<Player> players;
 | 
			
		||||
	@SuppressWarnings("unused")
 | 
			
		||||
	private int nb_players;
 | 
			
		||||
	private Bet bet;
 | 
			
		||||
	private Player attacker;
 | 
			
		||||
	private Player follower;
 | 
			
		||||
	private int attackScore;
 | 
			
		||||
//	private boolean little, twenty_one, excuse;
 | 
			
		||||
	private int attack_score;
 | 
			
		||||
//	private boolean little_end, twenty_one, excuse;
 | 
			
		||||
	private int ends;
 | 
			
		||||
	private int handle;
 | 
			
		||||
	@SuppressWarnings("unused")
 | 
			
		||||
	private int handle1, handle2, handle3, handle4, handle5, handle6;
 | 
			
		||||
	private List<Integer> handles;
 | 
			
		||||
	@SuppressWarnings("unused")
 | 
			
		||||
	private boolean misery1, misery2, misery3, misery4, misery5, misery6;
 | 
			
		||||
	private List<Boolean> miseries;
 | 
			
		||||
	private boolean littleForAttacker, littleForDefender;
 | 
			
		||||
	private boolean chelemAnnounced, chelemRealized;
 | 
			
		||||
	private int little_end;
 | 
			
		||||
	private boolean chelem_announced, chelem_realized;
 | 
			
		||||
	@SuppressWarnings("unused")
 | 
			
		||||
	private int score1, score2, score3, score4, score5, score6;
 | 
			
		||||
	private List<Integer> points;
 | 
			
		||||
 | 
			
		||||
@@ -92,6 +99,7 @@ public class Game {
 | 
			
		||||
				return Game.GameType.values()[3 + in.nextInt()];
 | 
			
		||||
			}
 | 
			
		||||
		}).registerTypeAdapter(Date.class, new TypeAdapter<Date>() {
 | 
			
		||||
			@SuppressLint("SimpleDateFormat")
 | 
			
		||||
			final DateFormat FORMAT = new SimpleDateFormat("yyyy-mm-dd HH:MM:ss");
 | 
			
		||||
 | 
			
		||||
			@Override
 | 
			
		||||
@@ -163,11 +171,11 @@ public class Game {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public int getAttackScore() {
 | 
			
		||||
		return attackScore;
 | 
			
		||||
		return attack_score;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void setAttackScore(int attackScore) {
 | 
			
		||||
		this.attackScore = attackScore;
 | 
			
		||||
	public void setAttackScore(int attack_score) {
 | 
			
		||||
		this.attack_score = attack_score;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public int getEnds() {
 | 
			
		||||
@@ -178,12 +186,16 @@ public class Game {
 | 
			
		||||
		this.ends = ends;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public int getHandle() {
 | 
			
		||||
		return handle;
 | 
			
		||||
	public int getHandle(Player player) {
 | 
			
		||||
		return handles.get(players.indexOf(player));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void setHandle(int handle) {
 | 
			
		||||
		this.handle = handle;
 | 
			
		||||
	public List<Integer> getHandles() {
 | 
			
		||||
		return handles;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void setHandles(List<Integer> handles) {
 | 
			
		||||
		this.handles = handles;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public List<Boolean> getMiseries() {
 | 
			
		||||
@@ -194,36 +206,28 @@ public class Game {
 | 
			
		||||
		this.miseries = miseries;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public boolean isLittleForAttacker() {
 | 
			
		||||
		return littleForAttacker;
 | 
			
		||||
	public int getLittleEnd() {
 | 
			
		||||
		return little_end;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void setLittleForAttacker(boolean littleForAttacker) {
 | 
			
		||||
		this.littleForAttacker = littleForAttacker;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public boolean isLittleForDefender() {
 | 
			
		||||
		return littleForDefender;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void setLittleForDefender(boolean littleForDefender) {
 | 
			
		||||
		this.littleForDefender = littleForDefender;
 | 
			
		||||
	public void setLittleEnd(int little_end) {
 | 
			
		||||
		this.little_end = little_end;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public boolean isChelemAnnounced() {
 | 
			
		||||
		return chelemAnnounced;
 | 
			
		||||
		return chelem_announced;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void setChelemAnnounced(boolean chelemAnnounced) {
 | 
			
		||||
		this.chelemAnnounced = chelemAnnounced;
 | 
			
		||||
	public void setChelemAnnounced(boolean chelem_announced) {
 | 
			
		||||
		this.chelem_announced = chelem_announced;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public boolean isChelemRealized() {
 | 
			
		||||
		return chelemRealized;
 | 
			
		||||
		return chelem_realized;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void setChelemRealized(boolean chelemRealized) {
 | 
			
		||||
		this.chelemRealized = chelemRealized;
 | 
			
		||||
	public void setChelemRealized(boolean chelem_realized) {
 | 
			
		||||
		this.chelem_realized = chelem_realized;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public int getPoints(Player player) {
 | 
			
		||||
@@ -235,36 +239,39 @@ public class Game {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void calculateScores() {
 | 
			
		||||
	//	int ends = (little ? 1 : 0) + (twenty_one ? 1 : 0) + (excuse ? 1 : 0);
 | 
			
		||||
	//	int ends = (little_end ? 1 : 0) + (twenty_one ? 1 : 0) + (excuse ? 1 : 0);
 | 
			
		||||
		int bound = ends == 0 ? 56 : ends == 1 ? 51 : ends == 2 ? 41 : 36;
 | 
			
		||||
		boolean win = attackScore >= bound;
 | 
			
		||||
		int gain = Math.abs(attackScore - bound);
 | 
			
		||||
		boolean win = attack_score >= bound;
 | 
			
		||||
		int gain = Math.abs(attack_score - bound);
 | 
			
		||||
		int score = 25;
 | 
			
		||||
		score += gain;
 | 
			
		||||
 | 
			
		||||
		score *= bet.getMultiplier();
 | 
			
		||||
 | 
			
		||||
		if (handle != 0)
 | 
			
		||||
			score += 10 * (Math.abs(handle) + 1);
 | 
			
		||||
		for (int i = 0; i < getGameType().getNbPlayers(); ++i) {
 | 
			
		||||
			Player player = getPlayers().get(i);
 | 
			
		||||
			if (getHandle(player) > 0)
 | 
			
		||||
				score += 10 * (getHandle(player) + 1);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (!win)
 | 
			
		||||
			score = -score;
 | 
			
		||||
 | 
			
		||||
		if (littleForAttacker)
 | 
			
		||||
		if (little_end != 0 && (players.get(little_end - 1) == attacker || players.get(little_end - 1) == follower))
 | 
			
		||||
			score += 10;
 | 
			
		||||
		else if (littleForDefender)
 | 
			
		||||
		else if (little_end != 0)
 | 
			
		||||
			score -= 10;
 | 
			
		||||
 | 
			
		||||
		if (chelemAnnounced) {
 | 
			
		||||
			if (chelemRealized)
 | 
			
		||||
		if (chelem_announced) {
 | 
			
		||||
			if (chelem_realized)
 | 
			
		||||
				score += 400;
 | 
			
		||||
			else
 | 
			
		||||
				score -= 200;
 | 
			
		||||
		}
 | 
			
		||||
		else if (chelemRealized)
 | 
			
		||||
		else if (chelem_realized)
 | 
			
		||||
			score += 200;
 | 
			
		||||
 | 
			
		||||
		attackScore = score;
 | 
			
		||||
		attack_score = score;
 | 
			
		||||
 | 
			
		||||
		Map<Player, Integer> scores = new HashMap<>();
 | 
			
		||||
 | 
			
		||||
@@ -389,6 +396,17 @@ public class Game {
 | 
			
		||||
						if (g.player6 != null)
 | 
			
		||||
							g.getPlayers().add(g.player6);
 | 
			
		||||
 | 
			
		||||
						g.handles = new ArrayList<>();
 | 
			
		||||
						g.getHandles().add(g.handle1);
 | 
			
		||||
						g.getHandles().add(g.handle2);
 | 
			
		||||
						g.getHandles().add(g.handle3);
 | 
			
		||||
						if (g.player4 != null)
 | 
			
		||||
							g.getHandles().add(g.handle4);
 | 
			
		||||
						if (g.player5 != null)
 | 
			
		||||
							g.getHandles().add(g.handle5);
 | 
			
		||||
						if (g.player6 != null)
 | 
			
		||||
							g.getHandles().add(g.handle6);
 | 
			
		||||
 | 
			
		||||
						g.miseries = new ArrayList<>();
 | 
			
		||||
						g.getMiseries().add(g.misery1);
 | 
			
		||||
						g.getMiseries().add(g.misery2);
 | 
			
		||||
@@ -411,8 +429,6 @@ public class Game {
 | 
			
		||||
						if (g.player6 != null)
 | 
			
		||||
							g.points.add(g.score6);
 | 
			
		||||
 | 
			
		||||
						System.out.println(g.toJson());
 | 
			
		||||
 | 
			
		||||
						for (Player p : g.getPlayers()) {
 | 
			
		||||
							p.addScore(g.getGameType(), g.getPoints(p));
 | 
			
		||||
						}
 | 
			
		||||
 
 | 
			
		||||
@@ -15,6 +15,7 @@ import java.net.HttpURLConnection;
 | 
			
		||||
import java.net.URL;
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.Collection;
 | 
			
		||||
import java.util.Comparator;
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
@@ -81,7 +82,6 @@ public class Player {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
	public static void updatePlayers() {
 | 
			
		||||
		System.err.println(getAllPlayers());
 | 
			
		||||
		Executors.newSingleThreadExecutor().execute(new Runnable() {
 | 
			
		||||
			@Override
 | 
			
		||||
			public void run() {
 | 
			
		||||
@@ -117,7 +117,14 @@ public class Player {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
    public static Collection<Player> getAllPlayers() {
 | 
			
		||||
    	return PLAYERS.values();
 | 
			
		||||
    	List<Player> list = new ArrayList<>(PLAYERS.values());
 | 
			
		||||
    	list.sort(new Comparator<Player>() {
 | 
			
		||||
			@Override
 | 
			
		||||
			public int compare(Player o1, Player o2) {
 | 
			
		||||
				return String.CASE_INSENSITIVE_ORDER.compare(o1.getName(), o2.getName());
 | 
			
		||||
			}
 | 
			
		||||
		});
 | 
			
		||||
    	return list;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public static Player getPlayerById(int id) {
 | 
			
		||||
 
 | 
			
		||||
@@ -98,7 +98,20 @@ public class NewGameFragment extends Fragment {
 | 
			
		||||
		final Switch chelem_announced = root.findViewById(R.id.chelem_announced);
 | 
			
		||||
		final Switch chelem_realized = root.findViewById(R.id.chelem_realized);
 | 
			
		||||
		final SeekBar little_end = root.findViewById(R.id.little_end);
 | 
			
		||||
		final SeekBar handle = root.findViewById(R.id.handle);
 | 
			
		||||
		final Button handle1 = root.findViewById(R.id.player1_handle);
 | 
			
		||||
		final Button handle2 = root.findViewById(R.id.player2_handle);
 | 
			
		||||
		final Button handle3 = root.findViewById(R.id.player3_handle);
 | 
			
		||||
		final Button handle4 = root.findViewById(R.id.player4_handle);
 | 
			
		||||
		final Button handle5 = root.findViewById(R.id.player5_handle);
 | 
			
		||||
		final Button handle6 = root.findViewById(R.id.player6_handle);
 | 
			
		||||
		final Button[] handles = new Button[]{handle1, handle2, handle3, handle4, handle5, handle6};
 | 
			
		||||
		final TextView handle1Text = root.findViewById(R.id.player1_handle_text);
 | 
			
		||||
		final TextView handle2Text = root.findViewById(R.id.player2_handle_text);
 | 
			
		||||
		final TextView handle3Text = root.findViewById(R.id.player3_handle_text);
 | 
			
		||||
		final TextView handle4Text = root.findViewById(R.id.player4_handle_text);
 | 
			
		||||
		final TextView handle5Text = root.findViewById(R.id.player5_handle_text);
 | 
			
		||||
		final TextView handle6Text = root.findViewById(R.id.player6_handle_text);
 | 
			
		||||
		final TextView[] handleTexts = new TextView[]{handle1Text, handle2Text, handle3Text, handle4Text, handle5Text, handle6Text};
 | 
			
		||||
		final ToggleButton misery1 = root.findViewById(R.id.player1_misery);
 | 
			
		||||
		final ToggleButton misery2 = root.findViewById(R.id.player2_misery);
 | 
			
		||||
		final ToggleButton misery3 = root.findViewById(R.id.player3_misery);
 | 
			
		||||
@@ -112,6 +125,7 @@ public class NewGameFragment extends Fragment {
 | 
			
		||||
		final TextView misery4Text = root.findViewById(R.id.player4_misery_text);
 | 
			
		||||
		final TextView misery5Text = root.findViewById(R.id.player5_misery_text);
 | 
			
		||||
		final TextView misery6Text = root.findViewById(R.id.player6_misery_text);
 | 
			
		||||
		final TextView[] miseryTexts = new TextView[]{misery1Text, misery2Text, misery3Text, misery4Text, misery5Text, misery6Text};
 | 
			
		||||
		final TextView points1 = root.findViewById(R.id.player1_points);
 | 
			
		||||
		final TextView points2 = root.findViewById(R.id.player2_points);
 | 
			
		||||
		final TextView points3 = root.findViewById(R.id.player3_points);
 | 
			
		||||
@@ -125,6 +139,7 @@ public class NewGameFragment extends Fragment {
 | 
			
		||||
		final TextView points4Text = root.findViewById(R.id.player4_points_text);
 | 
			
		||||
		final TextView points5Text = root.findViewById(R.id.player5_points_text);
 | 
			
		||||
		final TextView points6Text = root.findViewById(R.id.player6_points_text);
 | 
			
		||||
		final TextView[] pointsText = new TextView[]{points1Text, points2Text, points3Text, points4Text, points5Text, points6Text};
 | 
			
		||||
 | 
			
		||||
		final Runnable updateScore = new Runnable() {
 | 
			
		||||
			@Override
 | 
			
		||||
@@ -146,11 +161,13 @@ public class NewGameFragment extends Fragment {
 | 
			
		||||
				game.setPlayers(players);
 | 
			
		||||
				game.setBet(Game.Bet.values()[bet.getProgress()]);
 | 
			
		||||
				game.setEnds(nb_ends.getProgress());
 | 
			
		||||
				game.setHandle(handle.getProgress());
 | 
			
		||||
				List<Integer> handle = new ArrayList<>();
 | 
			
		||||
				for (int i = 0; i < game.getGameType().getNbPlayers(); ++i)
 | 
			
		||||
					handle.add((int) (1024.0F * (1.0F - handles[i].getAlpha())));
 | 
			
		||||
				game.setHandles(handle);
 | 
			
		||||
				game.setChelemAnnounced(chelem_announced.isChecked());
 | 
			
		||||
				game.setChelemRealized(chelem_realized.isChecked());
 | 
			
		||||
				game.setLittleForAttacker(little_end.getProgress() == 1);
 | 
			
		||||
				game.setLittleForDefender(little_end.getProgress() == 2);
 | 
			
		||||
				game.setLittleEnd(little_end.getProgress());
 | 
			
		||||
				List<Boolean> miseriesList = new ArrayList<>();
 | 
			
		||||
				for (int i = 0; i < game.getGameType().getNbPlayers(); ++i)
 | 
			
		||||
					miseriesList.add(miseries[i].isChecked());
 | 
			
		||||
@@ -182,18 +199,11 @@ public class NewGameFragment extends Fragment {
 | 
			
		||||
				dealer.setAdapter(adapter);
 | 
			
		||||
				follower.setAdapter(adapter);
 | 
			
		||||
 | 
			
		||||
				misery1Text.setText(((Player) player1.getSelectedItem()).getName());
 | 
			
		||||
				misery2Text.setText(((Player) player2.getSelectedItem()).getName());
 | 
			
		||||
				misery3Text.setText(((Player) player3.getSelectedItem()).getName());
 | 
			
		||||
				misery4Text.setText(((Player) player4.getSelectedItem()).getName());
 | 
			
		||||
				misery5Text.setText(((Player) player5.getSelectedItem()).getName());
 | 
			
		||||
				misery6Text.setText(((Player) player6.getSelectedItem()).getName());
 | 
			
		||||
				points1Text.setText(((Player) player1.getSelectedItem()).getName());
 | 
			
		||||
				points2Text.setText(((Player) player2.getSelectedItem()).getName());
 | 
			
		||||
				points3Text.setText(((Player) player3.getSelectedItem()).getName());
 | 
			
		||||
				points4Text.setText(((Player) player4.getSelectedItem()).getName());
 | 
			
		||||
				points5Text.setText(((Player) player5.getSelectedItem()).getName());
 | 
			
		||||
				points6Text.setText(((Player) player6.getSelectedItem()).getName());
 | 
			
		||||
				for (int i = 0; i < 6; ++i) {
 | 
			
		||||
					miseryTexts[i].setText(((Player) spinners[i].getSelectedItem()).getName());
 | 
			
		||||
					pointsText[i].setText(((Player) spinners[i].getSelectedItem()).getName());
 | 
			
		||||
					handleTexts[i].setText(((Player) spinners[i].getSelectedItem()).getName());
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				updateScore.run();
 | 
			
		||||
			}
 | 
			
		||||
@@ -221,21 +231,13 @@ public class NewGameFragment extends Fragment {
 | 
			
		||||
		};
 | 
			
		||||
 | 
			
		||||
		updatePlayers.onItemSelected(null, null, 0, 0);
 | 
			
		||||
		player1.setOnItemSelectedListener(updatePlayers);
 | 
			
		||||
		player2.setOnItemSelectedListener(updatePlayers);
 | 
			
		||||
		player3.setOnItemSelectedListener(updatePlayers);
 | 
			
		||||
		player4.setOnItemSelectedListener(updatePlayers);
 | 
			
		||||
		player5.setOnItemSelectedListener(updatePlayers);
 | 
			
		||||
		player6.setOnItemSelectedListener(updatePlayers);
 | 
			
		||||
		for (int i = 0; i < 6; ++i) {
 | 
			
		||||
			spinners[i].setOnItemSelectedListener(updatePlayers);
 | 
			
		||||
			miseries[i].setOnCheckedChangeListener(justUpdate2);
 | 
			
		||||
		}
 | 
			
		||||
		attacker.setOnItemSelectedListener(justUpdate);
 | 
			
		||||
		follower.setOnItemSelectedListener(justUpdate);
 | 
			
		||||
		dealer.setOnItemSelectedListener(justUpdate);
 | 
			
		||||
		misery1.setOnCheckedChangeListener(justUpdate2);
 | 
			
		||||
		misery2.setOnCheckedChangeListener(justUpdate2);
 | 
			
		||||
		misery3.setOnCheckedChangeListener(justUpdate2);
 | 
			
		||||
		misery4.setOnCheckedChangeListener(justUpdate2);
 | 
			
		||||
		misery5.setOnCheckedChangeListener(justUpdate2);
 | 
			
		||||
		misery6.setOnCheckedChangeListener(justUpdate2);
 | 
			
		||||
 | 
			
		||||
		nb_players.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
 | 
			
		||||
			@Override
 | 
			
		||||
@@ -259,16 +261,22 @@ public class NewGameFragment extends Fragment {
 | 
			
		||||
				nb_players_info.setText(resource);
 | 
			
		||||
 | 
			
		||||
				player4_layout.setVisibility(View.GONE);
 | 
			
		||||
				handle4Text.setVisibility(View.GONE);
 | 
			
		||||
				handle4.setVisibility(View.GONE);
 | 
			
		||||
				misery4Text.setVisibility(View.GONE);
 | 
			
		||||
				misery4.setVisibility(View.GONE);
 | 
			
		||||
				points4Text.setVisibility(View.GONE);
 | 
			
		||||
				points4.setVisibility(View.GONE);
 | 
			
		||||
				player5_layout.setVisibility(View.GONE);
 | 
			
		||||
				handle5Text.setVisibility(View.GONE);
 | 
			
		||||
				handle5.setVisibility(View.GONE);
 | 
			
		||||
				misery5Text.setVisibility(View.GONE);
 | 
			
		||||
				misery5.setVisibility(View.GONE);
 | 
			
		||||
				points5Text.setVisibility(View.GONE);
 | 
			
		||||
				points5.setVisibility(View.GONE);
 | 
			
		||||
				player6_layout.setVisibility(View.GONE);
 | 
			
		||||
				handle6Text.setVisibility(View.GONE);
 | 
			
		||||
				handle6.setVisibility(View.GONE);
 | 
			
		||||
				misery6Text.setVisibility(View.GONE);
 | 
			
		||||
				misery6.setVisibility(View.GONE);
 | 
			
		||||
				points6Text.setVisibility(View.GONE);
 | 
			
		||||
@@ -278,12 +286,16 @@ public class NewGameFragment extends Fragment {
 | 
			
		||||
				switch (progress + 3) {
 | 
			
		||||
					case 6:
 | 
			
		||||
						player6_layout.setVisibility(View.VISIBLE);
 | 
			
		||||
						handle6Text.setVisibility(View.VISIBLE);
 | 
			
		||||
						handle6.setVisibility(View.VISIBLE);
 | 
			
		||||
						misery6Text.setVisibility(View.VISIBLE);
 | 
			
		||||
						misery6.setVisibility(View.VISIBLE);
 | 
			
		||||
						points6Text.setVisibility(View.VISIBLE);
 | 
			
		||||
						points6.setVisibility(View.VISIBLE);
 | 
			
		||||
					case 5:
 | 
			
		||||
						player5_layout.setVisibility(View.VISIBLE);
 | 
			
		||||
						handle5Text.setVisibility(View.VISIBLE);
 | 
			
		||||
						handle5.setVisibility(View.VISIBLE);
 | 
			
		||||
						misery5Text.setVisibility(View.VISIBLE);
 | 
			
		||||
						misery5.setVisibility(View.VISIBLE);
 | 
			
		||||
						points5Text.setVisibility(View.VISIBLE);
 | 
			
		||||
@@ -291,6 +303,8 @@ public class NewGameFragment extends Fragment {
 | 
			
		||||
						follower_layout.setVisibility(View.VISIBLE);
 | 
			
		||||
					case 4:
 | 
			
		||||
						player4_layout.setVisibility(View.VISIBLE);
 | 
			
		||||
						handle4Text.setVisibility(View.VISIBLE);
 | 
			
		||||
						handle4.setVisibility(View.VISIBLE);
 | 
			
		||||
						misery4Text.setVisibility(View.VISIBLE);
 | 
			
		||||
						misery4.setVisibility(View.VISIBLE);
 | 
			
		||||
						points4Text.setVisibility(View.VISIBLE);
 | 
			
		||||
@@ -298,6 +312,8 @@ public class NewGameFragment extends Fragment {
 | 
			
		||||
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				little_end.setMax(progress + 3);
 | 
			
		||||
 | 
			
		||||
				updatePlayers.onItemSelected(null, null, 0, 0);
 | 
			
		||||
				updateScore.run();
 | 
			
		||||
			}
 | 
			
		||||
@@ -407,17 +423,13 @@ public class NewGameFragment extends Fragment {
 | 
			
		||||
			@Override
 | 
			
		||||
			public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
 | 
			
		||||
				TextView textView = root.findViewById(R.id.little_end_info);
 | 
			
		||||
				switch (progress) {
 | 
			
		||||
					case 1:
 | 
			
		||||
						textView.setText(R.string.for_attacker);
 | 
			
		||||
						break;
 | 
			
		||||
					case 2:
 | 
			
		||||
						textView.setText(R.string.for_defenser);
 | 
			
		||||
						break;
 | 
			
		||||
					default:
 | 
			
		||||
						textView.setText(R.string.no);
 | 
			
		||||
						break;
 | 
			
		||||
				}
 | 
			
		||||
				if (progress == 0)
 | 
			
		||||
					textView.setText(R.string.nobody);
 | 
			
		||||
				else
 | 
			
		||||
					textView.setText(((Player) spinners[progress - 1].getSelectedItem()).getName());
 | 
			
		||||
 | 
			
		||||
				if (!fromUser)
 | 
			
		||||
					return;
 | 
			
		||||
 | 
			
		||||
				updateScore.run();
 | 
			
		||||
			}
 | 
			
		||||
@@ -433,45 +445,32 @@ public class NewGameFragment extends Fragment {
 | 
			
		||||
 | 
			
		||||
		attack_points.setProgress(46);
 | 
			
		||||
 | 
			
		||||
		handle.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
 | 
			
		||||
		View.OnClickListener onHandleClick = new View.OnClickListener() {
 | 
			
		||||
			@Override
 | 
			
		||||
			public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
 | 
			
		||||
				TextView textView = root.findViewById(R.id.handle_info);
 | 
			
		||||
				switch (progress) {
 | 
			
		||||
					case -3:
 | 
			
		||||
						textView.setText(R.string.handle_3d);
 | 
			
		||||
						break;
 | 
			
		||||
					case -2:
 | 
			
		||||
						textView.setText(R.string.handle_2d);
 | 
			
		||||
						break;
 | 
			
		||||
					case -1:
 | 
			
		||||
						textView.setText(R.string.handle_1d);
 | 
			
		||||
			public void onClick(View v) {
 | 
			
		||||
				Button b = (Button) v;
 | 
			
		||||
				int x = ((int) (1024.0F * (1.0F - b.getAlpha())) + 1) % 4;
 | 
			
		||||
				b.setAlpha(1.0F - x / 1024.0F);
 | 
			
		||||
				switch (x) {
 | 
			
		||||
					case 0:
 | 
			
		||||
						b.setText(R.string.handle0);
 | 
			
		||||
						break;
 | 
			
		||||
					case 1:
 | 
			
		||||
						textView.setText(R.string.handle_1a);
 | 
			
		||||
						b.setText(R.string.handle1);
 | 
			
		||||
						break;
 | 
			
		||||
					case 2:
 | 
			
		||||
						textView.setText(R.string.handle_2a);
 | 
			
		||||
						b.setText(R.string.handle2);
 | 
			
		||||
						break;
 | 
			
		||||
					case 3:
 | 
			
		||||
						textView.setText(R.string.handle_3a);
 | 
			
		||||
						break;
 | 
			
		||||
					default:
 | 
			
		||||
						textView.setText(R.string.no_handle);
 | 
			
		||||
						b.setText(R.string.handle3);
 | 
			
		||||
						break;
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				updateScore.run();
 | 
			
		||||
			}
 | 
			
		||||
		};
 | 
			
		||||
 | 
			
		||||
			@Override
 | 
			
		||||
			public void onStartTrackingTouch(SeekBar seekBar) {
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			@Override
 | 
			
		||||
			public void onStopTrackingTouch(SeekBar seekBar) {
 | 
			
		||||
			}
 | 
			
		||||
		});
 | 
			
		||||
		for (int i = 0; i < 6; ++i)
 | 
			
		||||
			handles[i].setOnClickListener(onHandleClick);
 | 
			
		||||
 | 
			
		||||
		final Button btn = root.findViewById(R.id.add_game_button);
 | 
			
		||||
		btn.setOnClickListener(new View.OnClickListener() {
 | 
			
		||||
@@ -491,6 +490,7 @@ public class NewGameFragment extends Fragment {
 | 
			
		||||
							co.setRequestProperty("json", g.toJson());
 | 
			
		||||
							co.connect();
 | 
			
		||||
							co.getResponseCode();
 | 
			
		||||
							System.out.println(IOUtils.readLines(co.getInputStream()));
 | 
			
		||||
							co.disconnect();
 | 
			
		||||
 | 
			
		||||
							Game.updateGames();
 | 
			
		||||
@@ -512,11 +512,13 @@ public class NewGameFragment extends Fragment {
 | 
			
		||||
				game.setPlayers(players);
 | 
			
		||||
				game.setBet(Game.Bet.values()[bet.getProgress()]);
 | 
			
		||||
				game.setEnds(nb_ends.getProgress());
 | 
			
		||||
				game.setHandle(handle.getProgress());
 | 
			
		||||
				List<Integer> handle = new ArrayList<>();
 | 
			
		||||
				for (int i = 0; i < game.getGameType().getNbPlayers(); ++i)
 | 
			
		||||
					handle.add((int) (1024.0F * (1.0F - handles[i].getAlpha())));
 | 
			
		||||
				game.setHandles(handle);
 | 
			
		||||
				game.setChelemAnnounced(chelem_announced.isChecked());
 | 
			
		||||
				game.setChelemRealized(chelem_realized.isChecked());
 | 
			
		||||
				game.setLittleForAttacker(little_end.getProgress() == 1);
 | 
			
		||||
				game.setLittleForDefender(little_end.getProgress() == 2);
 | 
			
		||||
				game.setLittleEnd(little_end.getProgress());
 | 
			
		||||
				List<Boolean> miseriesList = new ArrayList<>();
 | 
			
		||||
				for (int i = 0; i < game.getGameType().getNbPlayers(); ++i)
 | 
			
		||||
					miseriesList.add(miseries[i].isChecked());
 | 
			
		||||
 
 | 
			
		||||
@@ -384,7 +384,7 @@
 | 
			
		||||
                    android:layout_width="match_parent"
 | 
			
		||||
                    android:layout_height="wrap_content"
 | 
			
		||||
                    android:layout_weight="1"
 | 
			
		||||
                    android:max="2"
 | 
			
		||||
                    android:max="4"
 | 
			
		||||
                    android:progress="0" />
 | 
			
		||||
 | 
			
		||||
                <TextView
 | 
			
		||||
@@ -392,48 +392,116 @@
 | 
			
		||||
                    android:layout_width="match_parent"
 | 
			
		||||
                    android:layout_height="wrap_content"
 | 
			
		||||
                    android:layout_weight="1"
 | 
			
		||||
                    android:text="@string/no"
 | 
			
		||||
                    android:text="@string/nobody"
 | 
			
		||||
                    android:textAlignment="center" />
 | 
			
		||||
            </LinearLayout>
 | 
			
		||||
 | 
			
		||||
        </LinearLayout>
 | 
			
		||||
 | 
			
		||||
        <TextView
 | 
			
		||||
            android:id="@+id/textView12"
 | 
			
		||||
            android:layout_width="wrap_content"
 | 
			
		||||
            android:layout_height="wrap_content"
 | 
			
		||||
            android:layout_weight="1"
 | 
			
		||||
            android:text="Poignée :" />
 | 
			
		||||
 | 
			
		||||
        <LinearLayout
 | 
			
		||||
            android:layout_width="match_parent"
 | 
			
		||||
            android:layout_height="wrap_content"
 | 
			
		||||
            android:orientation="horizontal">
 | 
			
		||||
 | 
			
		||||
            <TextView
 | 
			
		||||
                android:id="@+id/textView12"
 | 
			
		||||
            
 | 
			
		||||
            <HorizontalScrollView
 | 
			
		||||
                android:layout_width="wrap_content"
 | 
			
		||||
                android:layout_height="wrap_content"
 | 
			
		||||
                android:layout_weight="1"
 | 
			
		||||
                android:text="Poignée :" />
 | 
			
		||||
                android:layout_height="wrap_content">
 | 
			
		||||
 | 
			
		||||
            <LinearLayout
 | 
			
		||||
                android:layout_width="wrap_content"
 | 
			
		||||
                android:layout_height="wrap_content"
 | 
			
		||||
                android:layout_weight="1"
 | 
			
		||||
                android:orientation="vertical">
 | 
			
		||||
 | 
			
		||||
                <SeekBar
 | 
			
		||||
                    android:id="@+id/handle"
 | 
			
		||||
                    style="@style/Widget.AppCompat.SeekBar.Discrete"
 | 
			
		||||
                <TableLayout
 | 
			
		||||
                    android:layout_width="match_parent"
 | 
			
		||||
                    android:layout_height="wrap_content"
 | 
			
		||||
                    android:layout_weight="1"
 | 
			
		||||
                    android:max="3"
 | 
			
		||||
                    android:min="-3"
 | 
			
		||||
                    android:progress="0" />
 | 
			
		||||
                    android:layout_height="match_parent"
 | 
			
		||||
                    android:orientation="horizontal"
 | 
			
		||||
                    android:textAlignment="center">
 | 
			
		||||
 | 
			
		||||
                <TextView
 | 
			
		||||
                    android:id="@+id/handle_info"
 | 
			
		||||
                    android:layout_width="match_parent"
 | 
			
		||||
                    android:layout_height="wrap_content"
 | 
			
		||||
                    android:layout_weight="1"
 | 
			
		||||
                    android:text="@string/no_handle"
 | 
			
		||||
                    android:textAlignment="center" />
 | 
			
		||||
            </LinearLayout>
 | 
			
		||||
                    <TableRow
 | 
			
		||||
                        android:layout_width="match_parent"
 | 
			
		||||
                        android:layout_height="match_parent">
 | 
			
		||||
 | 
			
		||||
                        <TextView
 | 
			
		||||
                            android:id="@+id/player1_handle_text"
 | 
			
		||||
                            android:layout_width="wrap_content"
 | 
			
		||||
                            android:layout_height="wrap_content" />
 | 
			
		||||
 | 
			
		||||
                        <TextView
 | 
			
		||||
                            android:id="@+id/player2_handle_text"
 | 
			
		||||
                            android:layout_width="wrap_content"
 | 
			
		||||
                            android:layout_height="wrap_content" />
 | 
			
		||||
 | 
			
		||||
                        <TextView
 | 
			
		||||
                            android:id="@+id/player3_handle_text"
 | 
			
		||||
                            android:layout_width="wrap_content"
 | 
			
		||||
                            android:layout_height="wrap_content" />
 | 
			
		||||
 | 
			
		||||
                        <TextView
 | 
			
		||||
                            android:id="@+id/player4_handle_text"
 | 
			
		||||
                            android:layout_width="wrap_content"
 | 
			
		||||
                            android:layout_height="wrap_content" />
 | 
			
		||||
 | 
			
		||||
                        <TextView
 | 
			
		||||
                            android:id="@+id/player5_handle_text"
 | 
			
		||||
                            android:layout_width="wrap_content"
 | 
			
		||||
                            android:layout_height="wrap_content"
 | 
			
		||||
                            android:visibility="gone" />
 | 
			
		||||
 | 
			
		||||
                        <TextView
 | 
			
		||||
                            android:id="@+id/player6_handle_text"
 | 
			
		||||
                            android:layout_width="wrap_content"
 | 
			
		||||
                            android:layout_height="wrap_content"
 | 
			
		||||
                            android:visibility="gone" />
 | 
			
		||||
                    </TableRow>
 | 
			
		||||
 | 
			
		||||
                    <TableRow
 | 
			
		||||
                        android:layout_width="match_parent"
 | 
			
		||||
                        android:layout_height="match_parent">
 | 
			
		||||
 | 
			
		||||
                        <Button
 | 
			
		||||
                            android:id="@+id/player1_handle"
 | 
			
		||||
                            android:layout_width="wrap_content"
 | 
			
		||||
                            android:layout_height="wrap_content"
 | 
			
		||||
                            android:text="@string/handle0" />
 | 
			
		||||
 | 
			
		||||
                        <Button
 | 
			
		||||
                            android:id="@+id/player2_handle"
 | 
			
		||||
                            android:layout_width="wrap_content"
 | 
			
		||||
                            android:layout_height="wrap_content"
 | 
			
		||||
                            android:text="@string/handle0" />
 | 
			
		||||
 | 
			
		||||
                        <Button
 | 
			
		||||
                            android:id="@+id/player3_handle"
 | 
			
		||||
                            android:layout_width="wrap_content"
 | 
			
		||||
                            android:layout_height="wrap_content"
 | 
			
		||||
                            android:text="@string/handle0" />
 | 
			
		||||
 | 
			
		||||
                        <Button
 | 
			
		||||
                            android:id="@+id/player4_handle"
 | 
			
		||||
                            android:layout_width="wrap_content"
 | 
			
		||||
                            android:layout_height="wrap_content"
 | 
			
		||||
                            android:text="@string/handle0" />
 | 
			
		||||
 | 
			
		||||
                        <Button
 | 
			
		||||
                            android:id="@+id/player5_handle"
 | 
			
		||||
                            android:layout_width="wrap_content"
 | 
			
		||||
                            android:layout_height="wrap_content"
 | 
			
		||||
                            android:text="@string/handle0"
 | 
			
		||||
                            android:visibility="gone" />
 | 
			
		||||
 | 
			
		||||
                        <Button
 | 
			
		||||
                            android:id="@+id/player6_handle"
 | 
			
		||||
                            android:layout_width="wrap_content"
 | 
			
		||||
                            android:layout_height="wrap_content"
 | 
			
		||||
                            android:text="@string/handle0"
 | 
			
		||||
                            android:visibility="gone" />
 | 
			
		||||
                    </TableRow>
 | 
			
		||||
 | 
			
		||||
                </TableLayout>
 | 
			
		||||
            </HorizontalScrollView>
 | 
			
		||||
 | 
			
		||||
        </LinearLayout>
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -13,27 +13,25 @@
 | 
			
		||||
    <string name="attack_points">Points attaquants</string>
 | 
			
		||||
    <string name="defense_points">Points défenseurs</string>
 | 
			
		||||
    <string name="no">Non</string>
 | 
			
		||||
    <string name="for_attacker">Pour l\'attaquant</string>
 | 
			
		||||
    <string name="for_defenser">Pour le défenseur</string>
 | 
			
		||||
    <string name="null_end">Pas de bout</string>
 | 
			
		||||
	<string name="null_end">Pas de bout</string>
 | 
			
		||||
    <string name="one_end">Un bout</string>
 | 
			
		||||
    <string name="two_ends">Deux bouts</string>
 | 
			
		||||
    <string name="three_ends">Trois bouts</string>
 | 
			
		||||
    <string name="little">Petite</string>
 | 
			
		||||
    <string name="little_end">Petit au bout</string>
 | 
			
		||||
    <string name="guard">Garde</string>
 | 
			
		||||
    <string name="guard_without">Garde sans</string>
 | 
			
		||||
    <string name="guard_against">Garde contre</string>
 | 
			
		||||
    <string name="no_handle">Pas de poignée</string>
 | 
			
		||||
    <string name="handle_1a">Petite poignée (pour l\'attaquant)</string>
 | 
			
		||||
    <string name="handle_2a">Moyenne poignée (pour l\'attaquant)</string>
 | 
			
		||||
    <string name="handle_3a">Grande poignée (pour l\'attaquant)</string>
 | 
			
		||||
    <string name="handle_1d">Petite poignée (pour le défenseur)</string>
 | 
			
		||||
    <string name="handle_2d">Moyenne poignée (pour le défenseur)</string>
 | 
			
		||||
    <string name="handle_3d">Grande poignée (pour le défenseur)</string>
 | 
			
		||||
	<string name="handle1">Petite poignée</string>
 | 
			
		||||
    <string name="handle2">Moyenne poignée</string>
 | 
			
		||||
    <string name="handle3">Grande poignée</string>
 | 
			
		||||
    <string name="login">Se connecter</string>
 | 
			
		||||
	<string name="players3">3 joueurs</string>
 | 
			
		||||
    <string name="players4">4 joueurs</string>
 | 
			
		||||
    <string name="players5">5 joueurs</string>
 | 
			
		||||
    <string name="players6">6 joueurs</string>
 | 
			
		||||
    <string name="personal_stats">Statistiques individuelles</string>
 | 
			
		||||
    <string name="handle0">Pas de poignée</string>
 | 
			
		||||
	<string name="nobody">Personne</string>
 | 
			
		||||
	<string name="yes">Oui</string>
 | 
			
		||||
    <string name="little">Petite</string>
 | 
			
		||||
</resources>
 | 
			
		||||
@@ -13,27 +13,25 @@
 | 
			
		||||
    <string name="attack_points">Points attaquants</string>
 | 
			
		||||
    <string name="defense_points">Points défenseurs</string>
 | 
			
		||||
    <string name="no">Non</string>
 | 
			
		||||
    <string name="for_attacker">Pour l\'attaquant</string>
 | 
			
		||||
    <string name="for_defenser">Pour le défenseur</string>
 | 
			
		||||
    <string name="null_end">Pas de bout</string>
 | 
			
		||||
    <string name="one_end">Un bout</string>
 | 
			
		||||
    <string name="two_ends">Deux bouts</string>
 | 
			
		||||
    <string name="three_ends">Trois bouts</string>
 | 
			
		||||
    <string name="little">Petite</string>
 | 
			
		||||
    <string name="guard">Garde</string>
 | 
			
		||||
    <string name="guard_without">Garde sans</string>
 | 
			
		||||
    <string name="guard_against">Garde contre</string>
 | 
			
		||||
    <string name="no_handle">Pas de poignée</string>
 | 
			
		||||
    <string name="handle_1a">Petite poignée (pour l\'attaquant)</string>
 | 
			
		||||
    <string name="handle_2a">Moyenne poignée (pour l\'attaquant)</string>
 | 
			
		||||
    <string name="handle_3a">Grande poignée (pour l\'attaquant)</string>
 | 
			
		||||
    <string name="handle_1d">Petite poignée (pour le défenseur)</string>
 | 
			
		||||
    <string name="handle_2d">Moyenne poignée (pour le défenseur)</string>
 | 
			
		||||
    <string name="handle_3d">Grande poignée (pour le défenseur)</string>
 | 
			
		||||
    <string name="little_end">Petit au bout</string>
 | 
			
		||||
    <string name="guard">Guard</string>
 | 
			
		||||
    <string name="guard_without">Guard without</string>
 | 
			
		||||
    <string name="guard_against">Guard against</string>
 | 
			
		||||
	<string name="handle1">Little handle</string>
 | 
			
		||||
    <string name="handle2">Middle handle</string>
 | 
			
		||||
    <string name="handle3">Big handle</string>
 | 
			
		||||
    <string name="login">Se connecter</string>
 | 
			
		||||
    <string name="players3">3 joueurs</string>
 | 
			
		||||
    <string name="players4">4 joueurs</string>
 | 
			
		||||
    <string name="players5">5 joueurs</string>
 | 
			
		||||
    <string name="players6">6 joueurs</string>
 | 
			
		||||
    <string name="personal_stats">Statistiques individuelles</string>
 | 
			
		||||
    <string name="handle0">No handle</string>
 | 
			
		||||
    <string name="nobody">Nobody</string>
 | 
			
		||||
    <string name="yes">Yes</string>
 | 
			
		||||
    <string name="little">Little</string>
 | 
			
		||||
</resources>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user