|
1
|
|
|
<?php |
|
2
|
|
|
namespace Tarioch\EveapiFetcherBundle\Component\EveApi\Char; |
|
3
|
|
|
|
|
4
|
|
|
use JMS\DiExtraBundle\Annotation as DI; |
|
5
|
|
|
use Tarioch\EveapiFetcherBundle\Entity\ApiCall; |
|
6
|
|
|
use Pheal\Pheal; |
|
7
|
|
|
use Tarioch\EveapiFetcherBundle\Entity\ApiKey; |
|
8
|
|
|
use Tarioch\EveapiFetcherBundle\Entity\CharCharacterSheet; |
|
9
|
|
|
use Tarioch\EveapiFetcherBundle\Entity\CharAttributes; |
|
10
|
|
|
use Tarioch\EveapiFetcherBundle\Entity\CharCorporationRole; |
|
11
|
|
|
use Tarioch\EveapiFetcherBundle\Entity\CharCorporationRoleAtHq; |
|
12
|
|
|
use Tarioch\EveapiFetcherBundle\Entity\CharCorporationRoleAtBase; |
|
13
|
|
|
use Tarioch\EveapiFetcherBundle\Entity\CharCorporationRoleAtOther; |
|
14
|
|
|
use Tarioch\EveapiFetcherBundle\Entity\CharCorporationTitle; |
|
15
|
|
|
use Tarioch\EveapiFetcherBundle\Entity\CharSkill; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @DI\Service("tarioch.eveapi.char.CharacterSheet") |
|
19
|
|
|
* @SuppressWarnings(PHPMD.CouplingBetweenObjects) |
|
20
|
|
|
*/ |
|
21
|
|
|
class CharacterSheetUpdater extends AbstractCharUpdater |
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* @inheritdoc |
|
25
|
|
|
*/ |
|
26
|
|
|
public function update(ApiCall $call, ApiKey $key, Pheal $pheal) |
|
27
|
|
|
{ |
|
28
|
|
|
$charId = $call->getOwner()->getCharacterId(); |
|
29
|
|
|
|
|
30
|
|
|
$api = $pheal->charScope->CharacterSheet(array('characterID' => $charId)); |
|
31
|
|
|
|
|
32
|
|
|
$entity = new CharCharacterSheet($charId); |
|
33
|
|
|
$entity->setName($api->name); |
|
34
|
|
|
$entity->setDateOfBirth(new \DateTime($api->DoB)); |
|
35
|
|
|
$entity->setRace($api->race); |
|
36
|
|
|
$entity->setBloodLine($api->bloodLine); |
|
37
|
|
|
$entity->setAncestry($api->ancestry); |
|
38
|
|
|
$entity->setGender($api->gender); |
|
39
|
|
|
$entity->setCorporationId($api->corporationID); |
|
40
|
|
|
$entity->setCorporationName($api->corporationName); |
|
41
|
|
|
$entity->setAllianceId($api->allianceID); |
|
42
|
|
|
$entity->setAllianceName($api->allianceName); |
|
43
|
|
|
$entity->setCloneName($api->cloneName); |
|
44
|
|
|
$entity->setCloneSkillPoints($api->cloneSkillPoints); |
|
45
|
|
|
$entity->setBalance($api->balance); |
|
46
|
|
|
|
|
47
|
|
|
$attributes = new CharAttributes(); |
|
48
|
|
|
$entity->setAttributes($attributes); |
|
49
|
|
|
$attributesApi = $api->attributes; |
|
50
|
|
|
$attributes->setIntelligence($attributesApi->intelligence); |
|
51
|
|
|
$attributes->setMemory($attributesApi->memory); |
|
52
|
|
|
$attributes->setCharisma($attributesApi->charisma); |
|
53
|
|
|
$attributes->setPerception($attributesApi->perception); |
|
54
|
|
|
$attributes->setWillpower($attributesApi->willpower); |
|
55
|
|
|
|
|
56
|
|
|
foreach ($api->skills as $skillApi) { |
|
57
|
|
|
$skill = new CharSkill($entity); |
|
58
|
|
|
$skill->setTypeId($skillApi->typeID); |
|
59
|
|
|
$skill->setLevel($skillApi->level); |
|
60
|
|
|
$skill->setSkillpoints($skillApi->skillpoints); |
|
61
|
|
|
$skill->setPublished(filter_var($skillApi->published, FILTER_VALIDATE_BOOLEAN)); |
|
62
|
|
|
$entity->addSkill($skill); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
foreach ($api->corporationRoles as $roleApi) { |
|
66
|
|
|
$role = new CharCorporationRole($entity); |
|
67
|
|
|
$role->setRoleId($roleApi->roleID); |
|
68
|
|
|
$role->setRoleName($roleApi->roleName); |
|
69
|
|
|
$entity->addCorporationRole($role); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
foreach ($api->corporationRolesAtHQ as $roleApi) { |
|
73
|
|
|
$role = new CharCorporationRoleAtHq($entity); |
|
74
|
|
|
$role->setRoleId($roleApi->roleID); |
|
75
|
|
|
$role->setRoleName($roleApi->roleName); |
|
76
|
|
|
$entity->addCorporationRolesAtHq($role); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
foreach ($api->corporationRolesAtBase as $roleApi) { |
|
80
|
|
|
$role = new CharCorporationRoleAtBase($entity); |
|
81
|
|
|
$role->setRoleId($roleApi->roleID); |
|
82
|
|
|
$role->setRoleName($roleApi->roleName); |
|
83
|
|
|
$entity->addCorporationRolesAtBase($role); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
foreach ($api->corporationRolesAtOther as $roleApi) { |
|
87
|
|
|
$role = new CharCorporationRoleAtOther($entity); |
|
88
|
|
|
$role->setRoleId($roleApi->roleID); |
|
89
|
|
|
$role->setRoleName($roleApi->roleName); |
|
90
|
|
|
$entity->addCorporationRolesAtOther($role); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
foreach ($api->corporationTitles as $titleApi) { |
|
94
|
|
|
$title = new CharCorporationTitle($entity); |
|
95
|
|
|
$title->setTitleId($titleApi->titleID); |
|
96
|
|
|
$title->setTitleName($titleApi->titleName); |
|
97
|
|
|
$entity->addCorporationTitle($title); |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
$query = 'delete from TariochEveapiFetcherBundle:CharCharacterSheet c where c.characterId=:characterId'; |
|
101
|
|
|
$this->entityManager |
|
102
|
|
|
->createQuery($query) |
|
103
|
|
|
->setParameter('characterId', $charId) |
|
104
|
|
|
->execute(); |
|
105
|
|
|
|
|
106
|
|
|
$this->entityManager->persist($entity); |
|
107
|
|
|
return $api->cached_until; |
|
108
|
|
|
} |
|
109
|
|
|
} |
|
110
|
|
|
|