Commit 581ba8b8 authored by Peining's avatar Peining
Browse files

fix bug statistics

parent 614fd879
......@@ -31,7 +31,6 @@ import javafx.scene.chart.PieChart;
import javafx.scene.control.Button;
import javafx.scene.control.DatePicker;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.KeyCode;
......@@ -57,9 +56,13 @@ public class PlayerProfileController extends AbstractController{
@FXML
private Label lastNameText;
@FXML
private Label birthdayText;
private Label birthdayText;
@FXML
private TextField description;
private Label rateAll;
@FXML
private Label rateClassic;
@FXML
private Label rateBelgian;
@FXML
private ImageView image;
@FXML
......@@ -81,8 +84,6 @@ public class PlayerProfileController extends AbstractController{
@FXML
private Button avatar;
@FXML
private Button Description;
@FXML
private GridPane stat;
private PublicUser me;
private PublicUser other;
......@@ -110,22 +111,6 @@ public class PlayerProfileController extends AbstractController{
getIhmmain().toPlayerList();
}
@FXML
private void editDescription(ActionEvent event) throws IOException{
String text;
description.setEditable(true);
text = description.getText();
description.setText(text);
}
@FXML
private void closeEdit(KeyEvent event) throws IOException{
KeyCode code = event.getCode();
if (code == KeyCode.ENTER){
description.setEditable(false);
}
}
@FXML
private void edit(ActionEvent event) throws IOException{
attribut = ((Button)event.getSource()).getId();
......@@ -233,26 +218,40 @@ public class PlayerProfileController extends AbstractController{
}
public List<Integer> getData(PublicUser player,GameType type) throws DataException{
List<Integer> data = new ArrayList<>();
float rate = 0;
if (type == GameType.CLASSIC){
data.add(player.getNumberVictoriesClassic());
data.add(player.getNumberDefeatsClassic());
data.add(player.getNumberAbandonsClassic());
data.add(data.get(0)+data.get(1)+data.get(2));
if (data.get(3)!=0){
rate = ((float)data.get(0))/((float)data.get(3))*100;
}
rateClassic.setText("win rate: "+rate+"%");
}else if (type == GameType.BELGIAN){
data.add(player.getNumberVictoriesBelgian());
data.add(player.getNumberDefeatsBelgian());
data.add(player.getNumberAbandonsBelgian());
data.add(data.get(0)+data.get(1)+data.get(2));
if (data.get(3)!=0){
rate = ((float)data.get(0))/((float)data.get(3))*100;
}
rateBelgian.setText("win rate: "+rate+"%");
}
return data;
}
public List<Integer> getTotal( List<Integer> data1, List<Integer> data2){
List<Integer> data = new ArrayList<>();
float rate = 0;
int i = 0;
for (int a : data1){
data.add(data1.get(i)+data2.get(i));
i++;
}
if (data.get(3)!=0){
rate = ((float)data.get(0))/((float)data.get(3))*100;
}
rateAll.setText("win rate: "+rate+"%");
return data;
}
......@@ -273,7 +272,6 @@ public class PlayerProfileController extends AbstractController{
data1.addAll(data2);
data1.addAll(data3);
if (children.size()>8){
System.out.println("here!!!!!!!!!!!!!");
firstTime = false;
}
for (j=1;j<4;j++){
......@@ -282,11 +280,15 @@ public class PlayerProfileController extends AbstractController{
Label value = new Label();
value.setText(data1.get(index).toString());
stat.add(value, i, j);
GridPane.setColumnIndex(value, i);
GridPane.setRowIndex(value, j);
}
else{
for (Node node : children) {
if (GridPane.getColumnIndex(node) == i && GridPane.getRowIndex(node) == j) {
((Label)node).setText(data1.get(index).toString());
if (GridPane.getColumnIndex(node)!=null && GridPane.getRowIndex(node)!=null){
if (GridPane.getColumnIndex(node) == i && GridPane.getRowIndex(node) == j) {
((Label)node).setText(data1.get(index).toString());
}
}
}
}
......@@ -301,7 +303,6 @@ public class PlayerProfileController extends AbstractController{
birthday.setDisable(true);
password.setDisable(true);
avatar.setDisable(true);
Description.setDisable(true);
}
/**
......@@ -385,6 +386,5 @@ public class PlayerProfileController extends AbstractController{
birthday.setDisable(false);
password.setDisable(false);
avatar.setDisable(false);
Description.setDisable(false);
}
}
......@@ -38,7 +38,7 @@
</HBox>
</children>
</VBox>
<VBox prefHeight="261.0" prefWidth="306.0">
<VBox prefHeight="261.0" prefWidth="291.0">
<children>
<GridPane alignment="CENTER" prefHeight="257.0" prefWidth="282.0">
<children>
......@@ -73,34 +73,6 @@
<RowConstraints minHeight="10.0" prefHeight="30.0" valignment="CENTER" vgrow="SOMETIMES" />
</rowConstraints>
</GridPane>
</children>
</VBox>
<VBox prefHeight="261.0" prefWidth="291.0">
<children>
<HBox alignment="CENTER_LEFT" prefHeight="51.0" prefWidth="268.0">
<children>
<Label alignment="CENTER" contentDisplay="CENTER" text="Description">
<HBox.margin>
<Insets left="80.0" />
</HBox.margin></Label>
</children>
<VBox.margin>
<Insets />
</VBox.margin>
</HBox>
<HBox alignment="CENTER_RIGHT" prefHeight="165.0" prefWidth="268.0">
<children>
<TextField fx:id="description" editable="false" onKeyPressed="#closeEdit" prefHeight="144.0" prefWidth="219.0" text="Hello!" />
</children>
</HBox>
<HBox alignment="CENTER_LEFT" prefHeight="29.0" prefWidth="268.0">
<children>
<Button fx:id="Description" mnemonicParsing="false" onAction="#editDescription" text="edit" />
</children>
<padding>
<Insets left="70.0" />
</padding>
</HBox>
</children></VBox>
</children>
</HBox>
......@@ -184,9 +156,24 @@
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<PieChart fx:id="allMode" minHeight="-Infinity" minWidth="-Infinity" prefHeight="120.0" prefWidth="120.0" title="All Mode" titleSide="BOTTOM" />
<PieChart fx:id="classical" minHeight="-Infinity" minWidth="-Infinity" prefHeight="120.0" prefWidth="120.0" title="Classical" titleSide="BOTTOM" GridPane.columnIndex="1" />
<PieChart fx:id="belge" minHeight="-Infinity" minWidth="-Infinity" prefHeight="120.0" prefWidth="120.0" title="Belgian" titleSide="BOTTOM" GridPane.columnIndex="2" />
<PieChart fx:id="allMode" labelsVisible="false" legendVisible="false" minHeight="-Infinity" minWidth="-Infinity" prefHeight="238.0" prefWidth="152.0" stylesheets="@../../styles/ihmmain.css" title="All Mode" titleSide="BOTTOM" />
<PieChart fx:id="classical" labelsVisible="false" legendVisible="false" minHeight="-Infinity" minWidth="-Infinity" prefHeight="235.0" prefWidth="156.0" stylesheets="@../../styles/ihmmain.css" title="Classical" titleSide="BOTTOM" GridPane.columnIndex="1" />
<PieChart fx:id="belge" labelsVisible="false" legendVisible="false" minHeight="-Infinity" minWidth="-Infinity" prefHeight="234.0" prefWidth="146.0" stylesheets="@../../styles/ihmmain.css" title="Belgian" titleSide="BOTTOM" GridPane.columnIndex="2" />
</children>
</GridPane>
<GridPane GridPane.columnIndex="1">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Label fx:id="rateClassic" text="win rate:" GridPane.columnIndex="1" GridPane.halignment="CENTER" />
<Label fx:id="rateAll" text="win rate:" GridPane.halignment="CENTER" GridPane.valignment="CENTER" />
<Label fx:id="rateBelgian" text="win rate:" GridPane.columnIndex="2" GridPane.halignment="CENTER" />
</children>
</GridPane>
</children>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment