-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuserDetailsClass.php
More file actions
621 lines (586 loc) · 21.9 KB
/
userDetailsClass.php
File metadata and controls
621 lines (586 loc) · 21.9 KB
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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
<?php
require_once("tileClass.php");
require_once("knownTilesClass.php");
require_once("timedActionClass.php");
class UserDetails {
private $userid;
private $db;
private $knownTiles;
public static $WOOD = 1;
public static $TWIG = 2;
public static $MEAT = 3;
public static $BERRY = 4;
public static $STONE = 5;
public static $COAL = 6;
public static $IRON = 7;
public static $GOLD = 8;
public static $FISH = 9;
public static $MAX_TYPE = 9;
public static $PAYMENT_TIME = 604800; //1 hét
/*private $table_title = "userdetails";
private $table_userid = "userid";
private $table_knowntiles = "knowntiles";*/
function __construct($db,$userid) {
$this->db = $db;
$this->userid = $userid;
$this->addToTableIfNotExists();
$this->knownTiles = new KnownTiles($db,$userid);
}
//Visszaadja egy tömbben az összes felhasználó által felfedezett tile elemet
function getAllDiscoveredTiles() {
$knownTileArray = $this->getAllDiscoveredTilesRaw();
$tile = new Tile($this->db);
$result = null;
foreach($knownTileArray as $oneTile) {
$temp = $tile->getTileById($oneTile);
if($temp != null) {
$temp[$GLOBALS["table_tile_owner"]] = $this->getUserName($temp[$GLOBALS["table_tile_owner"]]);
$temp["examined"] = $this->knownTiles->isExamined($oneTile);
$result[]=$temp;
}
}
return $result;
}
//Visszaadja egy tömbben az összes felhasználó által felfedezett tile elemek ID-jét
function getAllDiscoveredTilesRaw() {
$knownTileArray = $this->knownTiles->getAll();
return $knownTileArray;
}
/*amikor felfedez egy koordinátát, akkor kell meghívni. Hozzáadja a tile táblához a tile-t, ha még nem létezett, és a knowntiles-ba berakja*/
function discoverTile($lat,$long) {
$tile = new Tile($this->db);
$id = $tile->addNewTile($lat,$long);
$this->addTileToKnownTile($id);
$this->setUserPlaceId($id);
return $tile->getTileById($id);
}
/*hozzáadja a megadott tile id-jét a knowntiles-hoz (a knowntiles végére beírja)*/
function addTileToKnownTile($tileid) {
$this->knownTiles->add($tileid);
}
/*hozzáadja a userid-t a táblához, üresen, ha még nem volt benne*/
function addToTableIfNotExists() {
if(!$this->isUserExists()) {
$sql = "INSERT INTO ".$GLOBALS["table_userdetails_title"]." (".$GLOBALS["table_userdetails_userid"].") VALUES (?)";
$stmt = $this->db->prepare($sql);
$stmt->execute(array($this->userid));
$stmt->fetch(PDO::FETCH_ASSOC);
}
}
/*Megnézi, hogy az adott userid szerepel-e már a táblában*/
function isUserExists() {
$sql = "SELECT * FROM ".$GLOBALS["table_userdetails_title"]." WHERE ".$GLOBALS["table_userdetails_userid"]." = ?";
$stmt = $this->db->prepare($sql);
$stmt->execute(array($this->userid));
$stmt->fetch(PDO::FETCH_ASSOC);
$count = $stmt->rowCount();
return ($count == 0 ? false : true);
}
/*Lekérdezi egy user nevét id által*/
function getUserName($userid) {
$sql = "SELECT ".$GLOBALS["table_user_username"]." FROM ".$GLOBALS["table_user_title"]." WHERE ".$GLOBALS["table_user_id"]." = ?";
$stmt = $this->db->prepare($sql);
$stmt->execute(array($userid));
$resultArray = $stmt->fetch(PDO::FETCH_ASSOC);
if($resultArray == null) {
return "";
}
return $resultArray[$GLOBALS["table_user_username"]];
}
/*Beállítja a usernek a tartózkodási helyét*/
function setUserPlaceId($id) {
$sql = "UPDATE ".$GLOBALS["table_userdetails_title"]." SET ".$GLOBALS["table_userdetails_placeid"]."= ? WHERE ".$GLOBALS["table_userdetails_userid"]." = ?";
$stmt = $this->db->prepare($sql);
$stmt->execute(array($id,$this->userid));
$stmt->fetch(PDO::FETCH_ASSOC);
}
/*Lekéri a usernek a tartózkodási helyét*/
function getUserPlaceId() {
$sql = "SELECT ".$GLOBALS["table_userdetails_placeid"]." FROM ".$GLOBALS["table_userdetails_title"]." WHERE ".$GLOBALS["table_userdetails_userid"]." = ?";
$stmt = $this->db->prepare($sql);
$stmt->execute(array($this->userid));
$resultArray = $stmt->fetch(PDO::FETCH_ASSOC);
return $resultArray;
}
/*Beállítja a usernek azt a helyet, ahova utazik*/
function setUserNewPlaceId($id) {
$sql = "UPDATE ".$GLOBALS["table_userdetails_title"]." SET ".$GLOBALS["table_userdetails_newplaceid"]."= ? WHERE ".$GLOBALS["table_userdetails_userid"]." = ?";
$stmt = $this->db->prepare($sql);
$stmt->execute(array($id,$this->userid));
$stmt->fetch(PDO::FETCH_ASSOC);
}
/*Lekéri a usernek azt a helyét, ahova tart*/
function getUserNewPlaceId() {
$sql = "SELECT ".$GLOBALS["table_userdetails_newplaceid"]." FROM ".$GLOBALS["table_userdetails_title"]." WHERE ".$GLOBALS["table_userdetails_userid"]." = ?";
$stmt = $this->db->prepare($sql);
$stmt->execute(array($this->userid));
$resultArray = $stmt->fetch(PDO::FETCH_ASSOC);
return $resultArray;
}
/*Visszaadja a már json kódolt adatokat a raktárról*/
public function getAllStorage($userid) {
$sql = "SELECT ".$GLOBALS["table_userdetails_storage"]." FROM ".$GLOBALS["table_userdetails_title"]." WHERE ".$GLOBALS["table_userdetails_userid"]." = ?";
$stmt = $this->db->prepare($sql);
$stmt->execute(array($userid));
$resultArray = $stmt->fetch(PDO::FETCH_ASSOC);
return $resultArray[$GLOBALS["table_userdetails_storage"]];
}
/**
* Lekérdezi, hogy tele van-e a raktár
* @param $userid
* @return bool
*/
public function isStorageFull($userid) {
$limit = $this->getStorageLimit();
$storageArray = json_decode($this->getAllStorage($userid));
$count = 0;
if($storageArray != null) {
foreach($storageArray as $anyag) {
$count += $anyag;
}
}
if($limit <= $count) {
return true;
}
else {
return false;
}
}
/*Beállítja a raktárban az adott típus nyersanyagainak számát. 3-as vagy 4-es hibát dob, ha tele van a raktár*/
public function setStorageResource($userid,$type,$resource) {
$storageArray = json_decode($this->getAllStorage($userid));
$count = 0;
if($storageArray != null) {
foreach($storageArray as $anyag) {
$count += $anyag;
}
}
else {
$storageArray = new stdClass();
}
/*if($count >= $this->getStorageLimit()) {
$result = array();
$result["hibaid"] = "3";
$result["hiba"] = Exceptions::getMessage(3);
echo json_encode($result);
return;
}*/
$count -= $this->getStorageResource($userid,$type);
if($count + $resource > $this->getStorageLimit()) {
$result = array();
$result["hibaid"] = "4";
$result["hiba"] = Exceptions::getMessage(4);
echo json_encode($result);
return;
}
$storageArray->$type = (int)$resource;
$sql = "UPDATE ".$GLOBALS["table_userdetails_title"]." SET ".$GLOBALS["table_userdetails_storage"]."= ? WHERE ".$GLOBALS["table_userdetails_userid"]." = ?";
$stmt = $this->db->prepare($sql);
$stmt->execute(array(json_encode($storageArray),$userid));
$stmt->fetch(PDO::FETCH_ASSOC);
}
/*Lekérdezi, hogy a raktárban hány megadott típusú nyersanyag található*/
public function getStorageResource($userid,$type) {
$storageArray = json_decode($this->getAllStorage($userid));
if($storageArray == null) {
return 0;
}
if(!property_exists($storageArray, $type)) {
return 0;
}
else {
return $storageArray->$type;
}
}
/*Lekérdezi a raktár kapacitását*/
public function getStorageLimit() {
$sql = "SELECT ".$GLOBALS["table_userdetails_storagelimit"]." FROM ".$GLOBALS["table_userdetails_title"]." WHERE ".$GLOBALS["table_userdetails_userid"]." = ?";
$stmt = $this->db->prepare($sql);
$stmt->execute(array($this->userid));
$resultArray = $stmt->fetch(PDO::FETCH_ASSOC);
return $resultArray[$GLOBALS["table_userdetails_storagelimit"]];
}
/*Beállítja a raktár kapacitását*/
public function setStorageLimit($storageLimit) {
$sql = "UPDATE ".$GLOBALS["table_userdetails_title"]." SET ".$GLOBALS["table_userdetails_storagelimit"]."= ? WHERE ".$GLOBALS["table_userdetails_userid"]." = ?";
$stmt = $this->db->prepare($sql);
$stmt->execute(array(json_encode($storageLimit),$this->userid));
$stmt->fetch(PDO::FETCH_ASSOC);
}
/*Lekérdezi a lakhelyet*/
public function getHomeId() {
$sql = "SELECT ".$GLOBALS["table_userdetails_homeid"]." FROM ".$GLOBALS["table_userdetails_title"]." WHERE ".$GLOBALS["table_userdetails_userid"]." = ?";
$stmt = $this->db->prepare($sql);
$stmt->execute(array($this->userid));
$resultArray = $stmt->fetch(PDO::FETCH_ASSOC);
return $resultArray[$GLOBALS["table_userdetails_homeid"]];
}
/*Beállítja a lakhelyet*/
public function setHomeId($homeid) {
$sql = "UPDATE ".$GLOBALS["table_userdetails_title"]." SET ".$GLOBALS["table_userdetails_homeid"]."= ? WHERE ".$GLOBALS["table_userdetails_userid"]." = ?";
$stmt = $this->db->prepare($sql);
$stmt->execute(array($homeid,$this->userid));
$stmt->fetch(PDO::FETCH_ASSOC);
}
/**
* Hozzáad egy intelligenciapontot
*/
public function addOneIpo() {
$ipocount = $this->getIpo();
$sql = "UPDATE ".$GLOBALS["table_userdetails_title"]." SET ".$GLOBALS["table_userdetails_ipo"]."= ? WHERE ".$GLOBALS["table_userdetails_userid"]." = ?";
$stmt = $this->db->prepare($sql);
$stmt->execute(array($ipocount+1,$this->userid));
$stmt->fetch(PDO::FETCH_ASSOC);
}
/**
* Lekérdezi hány intelligenciapontja van a karakternek
* @return mixed
*/
public function getIpo() {
$sql = "SELECT ".$GLOBALS["table_userdetails_ipo"]." FROM ".$GLOBALS["table_userdetails_title"]." WHERE ".$GLOBALS["table_userdetails_userid"]." = ?";
$stmt = $this->db->prepare($sql);
$stmt->execute(array($this->userid));
$resultArray = $stmt->fetch(PDO::FETCH_ASSOC);
return $resultArray[$GLOBALS["table_userdetails_ipo"]];
}
/**
* Beállítja, hogy hány intelligenciapontja legyen a karakternek
* @param $ipo
*/
public function setIpo($ipo) {
$sql = "UPDATE ".$GLOBALS["table_userdetails_title"]." SET ".$GLOBALS["table_userdetails_ipo"]."= ? WHERE ".$GLOBALS["table_userdetails_userid"]." = ?";
$stmt = $this->db->prepare($sql);
$stmt->execute(array($ipo,$this->userid));
$stmt->fetch(PDO::FETCH_ASSOC);
}
/**
* Lekérdezi a karakter által összes kifejlesztett épületet
* @return mixed
*/
public function getAllDevelopedBuildings() {
$sql = "SELECT ".$GLOBALS["table_userdetails_buildingdeveloped"]." FROM ".$GLOBALS["table_userdetails_title"]." WHERE ".$GLOBALS["table_userdetails_userid"]." = ?";
$stmt = $this->db->prepare($sql);
$stmt->execute(array($this->userid));
$resultArray = $stmt->fetch(PDO::FETCH_ASSOC);
return $resultArray[$GLOBALS["table_userdetails_buildingdeveloped"]];
}
/**
* Lekérdezi a karakter által összes kifejlesztett eszközt
* @return mixed
*/
public function getAllDevelopedTools() {
$sql = "SELECT ".$GLOBALS["table_userdetails_tooldeveloped"]." FROM ".$GLOBALS["table_userdetails_title"]." WHERE ".$GLOBALS["table_userdetails_userid"]." = ?";
$stmt = $this->db->prepare($sql);
$stmt->execute(array($this->userid));
$resultArray = $stmt->fetch(PDO::FETCH_ASSOC);
return $resultArray[$GLOBALS["table_userdetails_tooldeveloped"]];
}
/**
* Hozzáadja az épületet a kifejlesztett épületekhez
* @param $buildingid
* @param $buildinglevel
*/
public function addBuildingToDeveloped($buildingid,$buildinglevel) {
$bdArray = json_decode($this->getAllDevelopedBuildings());
if($bdArray == null) {
$bdArray = new stdClass();
}
$bdArray->$buildingid = $buildinglevel;
$sql = "UPDATE ".$GLOBALS["table_userdetails_title"]." SET ".$GLOBALS["table_userdetails_buildingdeveloped"]."= ? WHERE ".$GLOBALS["table_userdetails_userid"]." = ?";
$stmt = $this->db->prepare($sql);
$stmt->execute(array(json_encode($bdArray),$this->userid));
$stmt->fetch(PDO::FETCH_ASSOC);
}
/**
* Lekérdezi, hogy az épület ki van-e fejlesztve
* @param $buildingid
* @param $buildinglevel
* @return int
*/
public function isBuildingDeveloped($buildingid,$buildinglevel) {
$bdArray = json_decode($this->getAllDevelopedBuildings());
if($bdArray == null) {
return 0;
}
if(!isset($bdArray->$buildingid)) {
return 0;
}
if($bdArray->$buildingid >= $buildinglevel) {
return 1;
}
else {
return 0;
}
}
/**
* Hozzáaadja az eszközt a kifejlesztett eszközökhöz
* @param $tooltype
*/
public function addToolToDeveloped($tooltype) {
$bdArray = json_decode($this->getAllDevelopedTools());
if($bdArray == null) {
$bdArray = new stdClass();
}
$bdArray->$tooltype = 1;
$sql = "UPDATE ".$GLOBALS["table_userdetails_title"]." SET ".$GLOBALS["table_userdetails_tooldeveloped"]."= ? WHERE ".$GLOBALS["table_userdetails_userid"]." = ?";
$stmt = $this->db->prepare($sql);
$stmt->execute(array(json_encode($bdArray),$this->userid));
$stmt->fetch(PDO::FETCH_ASSOC);
}
/**
* Lekérdezi, hogy az eszköz ki van-e fejlesztve
* @param $toolid
* @return int
*/
public function isToolDeveloped($toolid) {
$bdArray = json_decode($this->getAllDevelopedTools());
if($bdArray == null) {
return 0;
}
if(!isset($bdArray->$toolid)) {
return 0;
}
if($bdArray->$toolid == 1) {
return 1;
}
else {
return 0;
}
}
/**
* Elmenti az adó egyik nyersanyagát
* @param $type
* @param $amount
*/
function setTaxResource($type,$amount) {
$taxArray = $this->getTaxResources($this->userid);
if($taxArray == null) {
$taxArray = new stdClass();
}
$taxArray->$type = (int)$amount;
$sql = "UPDATE ".$GLOBALS["table_userdetails_title"]." SET ".$GLOBALS["table_userdetails_tax"]."= ? WHERE ".$GLOBALS["table_userdetails_userid"]." = ?";
$stmt = $this->db->prepare($sql);
$stmt->execute(array(json_encode($taxArray),$this->userid));
$stmt->fetch(PDO::FETCH_ASSOC);
}
/**
* Lekéri a beállított adót
* @param $userid
* @return mixed|stdClass
*/
function getTaxResources($userid) {
$sql = "SELECT ".$GLOBALS["table_userdetails_tax"]." FROM ".$GLOBALS["table_userdetails_title"]." WHERE ".$GLOBALS["table_userdetails_userid"]." = ?";
$stmt = $this->db->prepare($sql);
$stmt->execute(array($userid));
$resultArray = $stmt->fetch(PDO::FETCH_ASSOC);
$array = json_decode($resultArray[$GLOBALS["table_userdetails_tax"]]);
if($array == null) {
$array = new stdClass();
}
for($i = 1; $i<=UserDetails::$MAX_TYPE; $i++) {
if($this->isTaxType($i)) {
if(!isset($array->$i)) {
$array->$i = 0;
}
}
}
return $array;
}
/**
* Kitörli a beállított adót
*/
function resetTaxResources() {
$sql = "UPDATE ".$GLOBALS["table_userdetails_title"]." SET ".$GLOBALS["table_userdetails_tax"]."= '' WHERE ".$GLOBALS["table_userdetails_userid"]." = ?";
$stmt = $this->db->prepare($sql);
$stmt->execute(array($this->userid));
$stmt->fetch(PDO::FETCH_ASSOC);
}
/**
* Lekéri az adott karakter adóját
* @param $userid - az adott karakter
* @param $tileid
* @return mixed|stdClass|string
*/
function getTaxForUser($userid,$tileid) {
$tile = new Tile($this->db);
$result=$tile->getTileById($tileid);
$ownerid = $result[$GLOBALS["table_tile_owner"]];
if($ownerid == $userid) { //ha ő a földesúr, akkor nem vonja le
return "";
}
$date = new DateTime();
if(abs($this->getTaxPaymentTime($userid)-$date->getTimestamp()) < UserDetails::$PAYMENT_TIME) {
return "";
}
$taxArray = $this->getTaxResources($ownerid);
$count = 0;
foreach($taxArray as $tax) {
$count += $tax;
}
if($count == 0) {
return "";
}
return $taxArray;
}
/**
* Befizeti az adott karakternek az adót
* @param $userid
* @param $tileid
* @return int
*/
function payTax($userid,$tileid) {
$taxArray = $this->getTaxForUser($userid,$tileid);
print_r($taxArray);
$date = new DateTime();
if(abs($this->getTaxPaymentTime($userid)-$date->getTimestamp()) < UserDetails::$PAYMENT_TIME) {
return 0;
}
$tile = new Tile($this->db);
$ownerid = $tile->getOwner($tileid);
//emberkétől levonás, földesúrhoz hozzáadás
foreach($taxArray as $type=>$amount) {
$inStorageUser = $this->getStorageResource($userid,$type);
$inStorageOwner = $this->getStorageResource($ownerid,$type);
if($amount > 0) {
if($inStorageUser <= $amount) {
$this->setStorageResource($userid,$type,0);
$this->setStorageResource($ownerid,$type,$inStorageOwner+$inStorageUser);
}
else {
$this->setStorageResource($userid,$type,$inStorageUser-$amount);
$this->setStorageResource($ownerid,$type,$inStorageOwner+$amount);
}
}
}
//idő átállítása
$this->setTaxPaymentTime($userid,$date->getTimestamp());
}
/**
* Lekérdezi, hogy mikor fizetett utoljára adót
* @param $userid
* @return mixed
*/
function getTaxPaymentTime($userid) {
$sql = "SELECT ".$GLOBALS["table_userdetails_taxtime"]." FROM ".$GLOBALS["table_userdetails_title"]." WHERE ".$GLOBALS["table_userdetails_userid"]." = ?";
$stmt = $this->db->prepare($sql);
$stmt->execute(array($userid));
$resultArray = $stmt->fetch(PDO::FETCH_ASSOC);
return $resultArray[$GLOBALS["table_userdetails_taxtime"]];
}
/**
* Beállítja, hogy mikor fizetett adót
* @param $userid
* @param $time
*/
function setTaxPaymentTime($userid,$time) {
$sql = "UPDATE ".$GLOBALS["table_userdetails_title"]." SET ".$GLOBALS["table_userdetails_taxtime"]."= ? WHERE ".$GLOBALS["table_userdetails_userid"]." = ?";
$stmt = $this->db->prepare($sql);
$stmt->execute(array($time,$userid));
$stmt->fetch(PDO::FETCH_ASSOC);
}
/*Lekéri, hogy egy tile hány embernek a lakhelye*/
function getTilePopulation($tileid) {
$sql = "SELECT COUNT(*) FROM ".$GLOBALS["table_userdetails_title"]." WHERE ".$GLOBALS["table_userdetails_homeid"]." = ?";
$stmt = $this->db->prepare($sql);
$stmt->execute(array($tileid));
$resultArray = $stmt->fetch(PDO::FETCH_ASSOC);
//print_r($resultArray);
return $resultArray["COUNT(*)"];
}
/**
* Kiszámolja két koordináta között a távolságot.
* @param $lat1
* @param $lon1
* @param $lat2
* @param $lon2
* @param $unit K - kilométer, M - mérföld
* @return float
*/
function distance($lat1, $lon1, $lat2, $lon2, $unit) {
$theta = $lon1 - $lon2;
$dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));
$dist = acos($dist);
$dist = rad2deg($dist);
$miles = $dist * 60 * 1.1515;
$unit = strtoupper($unit);
if ($unit == "K") {
return ($miles * 1.609344);
} else if ($unit == "N") {
return ($miles * 0.8684);
} else {
return $miles;
}
}
/**
* Elutazik a megadott helyszínre
* @param $placeid
* @return array
*/
public function travelToPlace($placeid) {
$timedAction = new TimedAction($this->db,$this->userid);
$timeArray = $timedAction->setTravelToPlace($this,$placeid);
return $timeArray;
}
/**
* Elkezdi a letelepedést
* @param $placeid
* @return array
*/
public function settleDown($placeid) {
$timedAction = new TimedAction($this->db,$this->userid);
$timeArray = $timedAction->setSettleDown($placeid);
return $timeArray;
}
/**
* Elkezdi kitermelni az első nyersanyagot
* @param $type
* @param $placeid
* @return array
*/
public function mineResource1($type,$placeid) {
$timedAction = new TimedAction($this->db,$this->userid);
$timeArray = $timedAction->setMineResource1($type,$placeid);
return $timeArray;
}
/**
* Elkezdi kitermelni a második nyersanyagot
* @param $type
* @param $placeid
* @return array
*/
public function mineResource2($type,$placeid) {
$timedAction = new TimedAction($this->db,$this->userid);
$timeArray = $timedAction->setMineResource2($type,$placeid);
return $timeArray;
}
/**
* Elkezdi kitermelni a harmadik nyersanyagot
* @param $type
* @param $placeid
* @return array
*/
public function mineResource3($type,$placeid) {
$timedAction = new TimedAction($this->db,$this->userid);
$timeArray = $timedAction->setMineResource3($type,$placeid);
return $timeArray;
}
/**
* Lekérdezi, hogy milyen nyersanyag lehet adó
* @param $type
* @return bool
*/
public function isTaxType($type) {
if($type == UserDetails::$WOOD ||
$type == UserDetails::$TWIG ||
$type == UserDetails::$MEAT ||
$type == UserDetails::$BERRY ||
$type == UserDetails::$STONE ||
$type == UserDetails::$FISH) {
return true;
}
else {
return false;
}
}
}
?>