forked from andreax79/tabboz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlavoro.cpp
295 lines (238 loc) · 9.25 KB
/
lavoro.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
/* Tabboz Simulator NG */
/* */
/* Copyright 2022-2023 Walter Agazzi */
/* Original Copyright 1997-2000 Andrea Bonomi */
/*
This file is part of Tabboz Simulator NG.
Tabboz Simulator NG is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Tabboz Simulator NG is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Tabboz Simulator NG. If not, see <http://www.gnu.org/licenses/>.
*/
#include "os.h"
#include <stdio.h>
#include <stdlib.h>
#include "zarrosim.h"
#include "dialogs.h"
#include "sound.h"
#include "calendario.h"
#include "eventi.h"
#include "lavoro.h"
#include "gui/GUILavoro.h"
/* Header per toolkit FLTK */
#include <FL/Fl.H>
#include <FL/fl_ask.H>
int numeroditta;
int stipendio;
int giorni_di_lavoro;
int impegno;
bool crocette_risposte[3][3]={0};
bool GiornoDiLavoro(const char *titolo_dialog);
STVARIE LavoroMem[] =
{ {0, 0, 0, 0, 0, 0, 0, 0, 0, "---"},
{0, 0, 0, 0, 0, 0, 0, 0, 0, "Magneti Budelli"},
{0, 0, 0, 0, 0, 0, 0, 0, 0, "Acciaierie Diamine"},
{0, 0, 0, 0, 0, 0, 0, 0, 0, "TestMec"},
{1, 0, 0, 0, 0, 0, 0, 0, 0, "T.I.B.B."},
{1, 0, 0, 0, 0, 0, 0, 0, 0, "October Heavy"},
{1, 0, 0, 0, 0, 0, 0, 0, 0, "Arlond's"},
{0, 0, 0, 0, 0, 0, 0, 0, 0, "286 - Computer d'annata"},
{1, 0, 0, 0, 0, 0, 0, 0, 0, "Ricopio" }
};
// | \stipendio base
// \lavoro fuori porta (solo con lo scooter puoi arrivarci...)
// FIXME: Implementare finestre dettagli aziende (inutili ma divertenti)
/* Aggiorna caselle stipendio - impegno */
void AggiornaLavoro(void)
{
if (numeroditta < 1) { // Nessun lavoro
lavoro_txt_ditta->value("---");
lavoro_val_stipendio->value(0);
lavoro_val_stipendio->deactivate();
lavoro_val_impegno->value(0);
lavoro_val_impegno->deactivate();
lavoro_val_impegno_percent->deactivate();
} else {
lavoro_txt_ditta->value(LavoroMem[numeroditta].nome);
lavoro_val_stipendio->activate();
lavoro_val_stipendio->value(CALCSOLDI(stipendio));
lavoro_val_impegno->activate();
lavoro_val_impegno->value(impegno);
}
lavoro_val_soldi->value(CALCSOLDI(Soldi));
win_lavoro->redraw();
}
/* Controlla quizzone e stabilisce se assunto o no */
void ControllaRisposte(int n_ditta, int n_scheda)
{
int Rcheck = 0;
/* n_scheda potrebbe servire in futuro se mai le risposte avranno un senso */
/* attualmente non servono a nulla... controlliamo semplicemente che sia stata data una sola risposta per domanda */
for(int i=0;i<3;i++) {
if (crocette_risposte[0][i]) Rcheck+=1;
if (crocette_risposte[1][i]) Rcheck+=10;
if (crocette_risposte[2][i]) Rcheck+=100;
}
if (Rcheck != 111) { // + di una crocetta per risposta o nessuna risposta...
MsgIcona(ICONA_STOP);
if (sesso == 'M') {
fl_message_title("Sei un po' stupido...");
fl_alert("Mi spieghi perchè dovremmo assumere qualcuno che non è neanche in grado di mettere delle crocette su un foglio ???");
}
else {
fl_message_title("Sei un po' stupida...");
fl_alert("Signorina, mi spieghi perchè dovremmo assumere qualcuno che non è neanche in grado di mettere delle crocette su un foglio ???");
}
Evento(false);
AggiornaLavoro();
return;
}
if (( Reputazione + Fortuna + (rand() % 80) ) > (rand() % 200) ) { // 3 risposte date, OK - con rep bassa e fortuna=0, la prob assunzione è circa del 25%
impegno=10 + (rand() % 20); // impegno iniziale random 10-29
giorni_di_lavoro=1;
stipendio=1000 + ( (rand() % 10) * 100); // stipendio random tra 1 mil e 1.9 mil
numeroditta=n_ditta + 1; //nelle dialog l'indice parte da zero
if (sound_active) TabbozPlaySound(505);
MsgIcona(ICONA_COOL);
fl_message_title("Hai trovato lavoro!");
if (sesso == 'M')
fl_alert("SEI STATO ASSUNTO!\nOra sei un felice dipendente della %s !", LavoroMem[numeroditta].nome);
else
fl_alert("SEI STATA ASSUNTA!\nOra sei una felice dipendente della %s !", LavoroMem[numeroditta].nome);
} else {
if (sound_active) TabbozPlaySound(504);
MsgIcona(ICONA_STOP);
fl_message_title("Niente da fare...");
if (sesso == 'M')
fl_alert("Mi dispiace ragazzo, ma non sei riuscito a superare il test...\nOra puoi anche portare la tua brutta faccia fuori dal mio ufficio,\nprima che ti faccia buttare fuori a calci... Grazie e arrivederci...");
else
fl_alert("Mi dispiace signorina, ma non è riuscita a superare il test...\nSe ne vada immediatamente, grazie...");
if (Reputazione > 10)
Reputazione-=2;
}
Evento(false);
AggiornaLavoro();
}
/* Per rassegnare le dimissioni */
void Licenziati(void)
{
char tmp[128];
if (!GiornoDiLavoro("Licenziati"))
return; //se è festa o disoccupato
MsgIcona(ICONA_DOMANDA);
fl_message_title("Mi licenzio!");
sprintf(tmp,"Sei proprio sicur%c di voler dare le dimissioni dalla %s ?",ao,LavoroMem[numeroditta].nome);
if(! fl_choice(tmp,"Sì, mi sono rotto","Ci ho ripensato...", 0)) {
numeroditta=0;
impegno=0;
giorni_di_lavoro=0;
stipendio=0;
Evento(false);
}
AggiornaLavoro();
}
/* Calcola i soldi spettanti dopo licenziamento */
void CalcolaTFR(void) {
int tfr;
tfr = stipendio * (giorni_di_lavoro / 30.0 );
MsgIcona(ICONA_INFO);
fl_message_title("Trattamento di fine rapporto");
fl_message("Il tuo T.F.R. ammonta a %s", MostraSoldi(tfr));
Soldi+=tfr;
}
/* Incrementa l'impegno */
void Lavora(void)
{
if (! GiornoDiLavoro("Lavora"))
return;
if (impegno < 85)
impegno++;
if (sound_active) TabbozPlaySound(501);
Evento(false);
AggiornaLavoro();
}
/* Aumenta impegno perdendo rep e fama */
void FaiIlLeccaculo(void)
{
if (sesso == 'M') {
if (! GiornoDiLavoro("Fai il leccaculo"))
return;
} else {
if (! GiornoDiLavoro("Fai la leccaculo"))
return;
}
if (sound_active) TabbozPlaySound(503);
if (Reputazione > 20 ) /* Facendo il leccaculo perdi reputazione e fama... */
Reputazione-=1;
if (impegno < 99)
impegno++;
if( (rand() % (Fortuna+3)) == 0 ) // evento casuale per sfigati
Evento(false);
AggiornaLavoro();
}
/* Routine per incrementare stipendio se impegno è molto alto */
void ChiediAumento(void)
{
if (!GiornoDiLavoro("Chiedi aumento salario"))
return; //se è festa o disoccupato
fl_message_title("Chiedi un aumento");
if (impegno > 90) {
if ((30 + Fortuna) > (30 + rand() % 50)) {
MsgIcona(ICONA_COOL);
fl_message("Forse per questa volta potremmo darti qualcosina in più...");
if (sound_active) TabbozPlaySound(1100);
//stipendio+=((random(1)+1) * 100); // questa formula non funziona perchè random(1) restituisce interi
stipendio+=( (rand() % 10) + 10 ) * 10; // BUGFIX questa sì
impegno-=30;
Evento(false);
} else {
MsgIcona(ICONA_AVVISO);
if (sesso == 'M' ) // visto che l'impegno è >90, sfanculata politically correct
fl_alert("Siamo soddisfatti del tuo rendimento, ma attualmente\nnon possiamo applicare variazioni agli emolumenti per i dipendenti.");
else
fl_alert("Siamo soddisfatti del tuo rendimento, ma attualmente\nnon possiamo applicare variazioni agli emolumenti per i dipendenti.");
impegno-=20;
Evento(false);
}
} else {
MsgIcona(ICONA_STOP);
fl_alert("Che cosa vorresti??? SCORDATELO!!!!");
}
AggiornaLavoro();
}
/* Aumenta rep perdendo impegno */
void Sciopera(void)
{
if (! GiornoDiLavoro("Sciopera"))
return;
if (sound_active) TabbozPlaySound(502);
if (Reputazione < 85 )
Reputazione+=10;
if (impegno > 19 )
impegno-=15;
if( (rand() % (Fortuna+3)) == 0 ) // evento casuale per sfigati
Evento(false);
Evento(false); // due eventi? azz...
AggiornaLavoro();
}
/* Controlla che sia un giorno lavorativo e che il tabbozzo non sia disoccupato */
bool GiornoDiLavoro(const char *titolo_dialog)
{
fl_message_title(titolo_dialog);
MsgIcona(ICONA_AVVISO);
if (numeroditta < 1) {
fl_alert("Forse non ti ricordi che sei disokkupat%c...",ao);
return false;
}
if ( ( x_vacanza == 2 ) || (x_giornoset == 6) ) { // BUGFIX le ditte sono chiuse al sabato...
fl_alert("Arrivat%c davanti ai cancelli della ditta li trovi irrimediabilmente chiusi...",ao);
return false;
}
return true;
}