a97361b37a346a6d4f013d3d8f44cbee622e6ba3
[aspt.git] / playerdetail.cc
1 /*******************************************************************
2 Jan Cermak | johniez | aspt.johniez.com
3 Creative Commons 2.5 Attribution-NonCommercial-NoDerivs 2.5 license
4 http://creativecommons.org/licenses/by-nc-nd/2.5/legalcode
5 *******************************************************************/
6
7 #include "playerdetail.h"
8
9 PlayerDetail::PlayerDetail(int idx, QWidget * parent): QWidget(parent), i(idx) {
10         mainLayout = new QVBoxLayout;
11         QString info = "<table>";
12         info += "<tr><td>" + pls[i].fname + " " + pls[i].lname + "</td><td>[" + pls[i].age + "]</td></td>";
13         info += "<tr><td>" + tr("Position") + "</td><td><span style=\"color:red;\">" + pls[i].position + "</span></td></td>";
14         info += "<td><td>" + tr("Rating") + "</td><td><span style=\"color:red;\">" + pls[i].rating + "%</span></td></tr>";
15         info += "<tr><td>" + tr("Moral") + "</td><td><span style=\"color:red;\">" + pls[i].morale + "%</span></td></td>";
16         info += "<td><td>" + tr("Aggresion") + "</td><td><span style=\"color:red;\">" + pls[i].aggresion + "%</span></td></tr>";
17         info += "<tr><td>" + tr("Fitness") + "</td><td><span style=\"color:red;\">" + pls[i].fitness + "%</span></td></td>";
18         info += "<td><td>" + tr("Experience") + "</td><td><span style=\"color:red;\">" + pls[i].experience + "%</span></td></tr>";
19         info += "<tr><td>" + tr("Stamina") + "</td><td><span style=\"color:red;\">" + pls[i].condition + "%</span></td></td>";
20         info += "<td><td>" + tr("Best rate") + "</td><td><span style=\"color:red;\">" + pls[i].bestRate + "</span></td></tr>";
21         info += "<tr><td>" + tr("Form") + "</td><td><span style=\"color:red;\">" + pls[i].form + "</span></td></tr>";
22         info += "<tr></tr>";
23         info += "<tr><td>" + tr("Speed") + "</td><td><span style=\"color:red;\">" + pls[i].speed + "%</span></td></td>";
24         info += "<td><td>" + tr("Ball controll") + "</td><td><span style=\"color:red;\">" + pls[i].ballCntrl + "%</span></td></tr>";
25         if(pls[i].position=="GK") {
26                 info += "<tr><td>" + tr("Courage") + "</td><td><span style=\"color:red;\">" + pls[i].skill[0] + "%</span></td></td>";
27                 info += "<td><td>" + tr("Flexibility") + "</td><td><span style=\"color:red;\">" + pls[i].skill[1] + "%</span></td></tr>";
28                 info += "<tr><td>" + tr("Jumping") + "</td><td><span style=\"color:red;\">" + pls[i].skill[2] + "%</span></td></td>";
29                 info += "<td><td>" + tr("Goalkicks") + "</td><td><span style=\"color:red;\">" + pls[i].skill[3] + "%</span></td></tr>";
30                 info += "<tr><td>" + tr("Play along") + "</td><td><span style=\"color:red;\">" + pls[i].specSkill[0] + "%</span></td></td>";
31                 info += "<td><td>" + tr("Reflex") + "</td><td><span style=\"color:red;\">" + pls[i].specSkill[1] + "%</span></td></tr>";
32         } else if(pls[i].position == "LB" || pls[i].position == "CB" || pls[i].position == "RB" || pls[i].position == "SW") {
33                 info += "<tr><td>" + tr("Passing") + "</td><td><span style=\"color:red;\">" + pls[i].skill[0] + "%</span></td></td>";
34                 info += "<td><td>" + tr("Shooting") + "</td><td><span style=\"color:red;\">" + pls[i].skill[1] + "%</span></td></tr>";
35                 info += "<tr><td>" + tr("Play it out") + "</td><td><span style=\"color:red;\">" + pls[i].skill[2] + "%</span></td></td>";
36                 info += "<td><td>" + tr("Strength") + "</td><td><span style=\"color:red;\">" + pls[i].skill[3] + "%</span></td></tr>";
37                 info += "<tr><td>" + tr("Heading") + "</td><td><span style=\"color:red;\">" + pls[i].specSkill[0] + "%</span></td></td>";
38                 info += "<td><td>" + tr("Tackling") + "</td><td><span style=\"color:red;\">" + pls[i].specSkill[1] + "%</span></td></tr>";
39         } else if(pls[i].position == "LM" || pls[i].position == "CM" || pls[i].position == "RM") {
40                 info += "<tr><td>" + tr("Heading") + "</td><td><span style=\"color:red;\">" + pls[i].skill[0] + "%</span></td></td>";
41                 info += "<td><td>" + tr("Shooting") + "</td><td><span style=\"color:red;\">" + pls[i].skill[1] + "%</span></td></tr>";
42                 info += "<tr><td>" + tr("Tackling") + "</td><td><span style=\"color:red;\">" + pls[i].skill[2] + "%</span></td></td>";
43                 info += "<td><td>" + tr("Strength") + "</td><td><span style=\"color:red;\">" + pls[i].skill[3] + "%</span></td></tr>";
44                 info += "<tr><td>" + tr("Passing") + "</td><td><span style=\"color:red;\">" + pls[i].specSkill[0] + "%</span></td></td>";
45                 info += "<td><td>" + tr("Playmaking") + "</td><td><span style=\"color:red;\">" + pls[i].specSkill[1] + "%</span></td></tr>";
46         } else if(pls[i].position == "LF" || pls[i].position == "CF" || pls[i].position == "RF") {
47                 info += "<tr><td>" + tr("Passing") + "</td><td><span style=\"color:red;\">" + pls[i].skill[0] + "%</span></td></td>";
48                 info += "<td><td>" + tr("Tackling") + "</td><td><span style=\"color:red;\">" + pls[i].skill[1] + "%</span></td></tr>";
49                 info += "<tr><td>" + tr("Insight") + "</td><td><span style=\"color:red;\">" + pls[i].skill[2] + "%</span></td></td>";
50                 info += "<td><td>" + tr("Strength") + "</td><td><span style=\"color:red;\">" + pls[i].skill[3] + "%</span></td></tr>";
51                 info += "<tr><td>" + tr("Heading") + "</td><td><span style=\"color:red;\">" + pls[i].specSkill[0] + "%</span></td></td>";
52                 info += "<td><td>" + tr("Shooting") + "</td><td><span style=\"color:red;\">" + pls[i].specSkill[1] + "%</span></td></tr>";
53         }
54         info += "</table><hr><table>";
55         int hidden = ((pls[i].rating.toInt() * 15) - pls[i].morale.toInt() - pls[i].experience.toInt() - pls[i].condition.toInt() - pls[i].speed.toInt() - pls[i].ballCntrl.toInt() - pls[i].skill[0].toInt() - pls[i].skill[1].toInt() - pls[i].skill[2].toInt() - pls[i].skill[3].toInt() - 2*pls[i].specSkill[0].toInt() - 2*pls[i].specSkill[1].toInt())/2;
56         info += "<tr><td>" + tr("Estimated Hidden") + "</td><td><span style=\"color:red;\">" + QString().setNum(hidden) + "%</span></td></tr>";
57         if(pls[i].morale.toInt()<100) {
58                 int rating_mor = ((pls[i].rating.toInt() * 15) + (100 - pls[i].morale.toInt())) / 15;
59                 info += "<tr><td>" + tr("Rating with 100% morale") + "</td><td><span style=\"color:red;\">" + QString().setNum(rating_mor) + "%</span></td></tr>";
60         }
61         if(pls[i].experience.toInt()<100 && pls[i].morale.toInt()<100) {
62                 int rating_all = ((pls[i].rating.toInt() * 15) + (100 - pls[i].experience.toInt()) + (100 - pls[i].morale.toInt())) / 15;
63                 info += "<tr><td>" + tr("Rating with 100% experience and morale") + "</td><td><span style=\"color:red;\">" + QString().setNum(rating_all) + "%</span></td></tr>";
64         } else if(pls[i].experience.toInt()<100) {
65                 int rating_exp = ((pls[i].rating.toInt() * 15) + (100 - pls[i].experience.toInt())) / 15;
66                 info += "<tr><td>" + tr("Rating with 100% experience") + "</td><td><span style=\"color:red;\">" + QString().setNum(rating_exp) + "%</span></td></tr>";
67         }
68         info += "<tr><td></td><td></td></tr>";
69         info += "<tr><td>" + tr("Order") + " - " + tr("Normal") + "</td><td>0.00%</td></tr>";
70         if(pls[i].position=="GK") {
71                 int plus = pls[i].specSkill[0].toInt() + pls[i].speed.toInt();
72                 int minus = pls[i].specSkill[1].toInt() + pls[i].skill[0].toInt();
73                 QString temp;
74                 temp.setNum((float)(plus-minus)/20, 'f', 2);
75                 info += "<tr><td>" + tr("Order") + " - " + tr("Play along") + "</td><td>" + temp + "%</td></tr>";
76         } else if(pls[i].position == "LB" || pls[i].position == "RB") {
77                 int plus = pls[i].skill[0].toInt() + pls[i].speed.toInt();
78                 int minus = pls[i].specSkill[0].toInt() + pls[i].skill[3].toInt();
79                 QString temp;
80                 temp.setNum((float)(plus-minus)/20, 'f', 2);
81                 QString text = "<tr><td>" + tr("Order") + " - " + tr("Play along wing") + "</td><td>" + temp + "%</td></tr>";
82                 plus = pls[i].skill[0].toInt();
83                 minus = pls[i].specSkill[1].toInt();
84                 temp.setNum((float)(plus-minus)/20, 'f', 2);
85                 info += text + "<tr><td>" + tr("Order") + " - " + tr("Play it out") + "</td><td>" + temp + "%</td></tr>";
86         } else if(pls[i].position == "CB") {
87                 int plus = pls[i].skill[0].toInt();
88                 int minus = pls[i].specSkill[1].toInt();
89                 QString temp;
90                 temp.setNum((float)(plus-minus)/20, 'f', 2);
91                 info += "<tr><td>" + tr("Order") + " - " + tr("Play it out") + "</td><td>" + temp + "%</td></tr>";
92         } else if(pls[i].position == "LM" || pls[i].position == "RM") {
93                 int plus = pls[i].specSkill[0].toInt() + pls[i].speed.toInt();
94                 int minus = pls[i].skill[3].toInt() + pls[i].skill[0].toInt();
95                 QString temp, text;
96                 temp.setNum((float)(plus-minus)/20, 'f', 2);
97                 text = "<tr><td>" + tr("Order") + " - " + tr("Play along wing") + "</td><td>" + temp + "%</td></tr>";
98                 plus = pls[i].specSkill[0].toInt() + pls[i].specSkill[1].toInt();
99                 minus = pls[i].skill[0].toInt() + pls[i].skill[1].toInt();
100                 temp.setNum((float)(plus-minus)/20, 'f', 2);
101                 info += text + "<tr><td>" + tr("Order") + " - " + tr("Passing") + "</td><td>" + temp + "%</td></tr>";
102         } else if(pls[i].position == "CM") {
103                 int plus = pls[i].specSkill[0].toInt() + pls[i].specSkill[1].toInt();
104                 int minus = pls[i].skill[0].toInt() + pls[i].skill[1].toInt();
105                 QString temp;
106                 temp.setNum((float)(plus-minus)/20, 'f', 2);
107                 info += "<tr><td>" + tr("Order") + " - " + tr("Passing") + "</td><td>" + temp + "%</td></tr>";
108         } else if(pls[i].position == "LF" || pls[i].position == "CF" || pls[i].position == "RF") {
109                 int plus = pls[i].specSkill[1].toInt() + pls[i].skill[1].toInt();
110                 int minus = pls[i].specSkill[0].toInt() + pls[i].skill[0].toInt();
111                 QString temp, text;
112                 temp.setNum((float)(plus-minus)/20, 'f', 2);
113                 text = "<tr><td>" + tr("Order") + " - " + tr("Own chance") + "</td><td>" + temp + "%</td></tr>";
114                 if(pls[i].position == "CF") {
115                         plus = pls[i].specSkill[0].toInt() + pls[i].skill[3].toInt();
116                         minus = pls[i].specSkill[1].toInt() + pls[i].skill[1].toInt();
117                         temp.setNum((float)(plus-minus)/20, 'f', 2);
118                         text += "<tr><td>" + tr("Order") + " - " + tr("Targetman") + "</td><td>" + temp + "%</td></tr>";
119                 }
120                 plus = pls[i].skill[2].toInt();
121                 minus = pls[i].skill[1].toInt();
122                 temp.setNum((float)(plus-minus)/20, 'f', 2);
123                 info += text + "<tr><td>" + tr("Order") + " - " + tr("Free role") + "</td><td>" + temp + "%</td></tr>";
124         }
125         info += "</table>";
126         info += tr("<br>How much points of performance orders add,<br>or remove if result is negative.");
127         
128         player = new QLabel(info);
129         mainLayout->addWidget(player);
130         setLayout(mainLayout);
131 }
132
133 PlayerDetail::~PlayerDetail() {
134         delete player;
135         delete mainLayout;
136 }
137