Quests/Fixup
* fix converting min/max reputation requirements to TC condition on detail page (it still lacks the exact amount) * also Game::getReputationLevelForPoints was off by 1
This commit is contained in:
parent
5f7247b292
commit
c6d92031c5
2 changed files with 32 additions and 20 deletions
|
|
@ -984,11 +984,29 @@ class QuestBaseResponse extends TemplateResponse implements ICache
|
|||
->getByCondition(Type::QUEST, $this->typeId)
|
||||
->prepare();
|
||||
|
||||
if ($_ = $this->subject->getField('reqMinRepFaction'))
|
||||
$cnd->addExternalCondition(Conditions::SRC_QUEST_AVAILABLE, '0:'.$this->typeId, [Conditions::REPUTATION_RANK, $_, 1 << Game::getReputationLevelForPoints($this->subject->getField('reqMinRepValue'))]);
|
||||
|
||||
if ($_ = $this->subject->getField('reqMaxRepFaction'))
|
||||
$cnd->addExternalCondition(Conditions::SRC_QUEST_AVAILABLE, '0:'.$this->typeId, [-Conditions::REPUTATION_RANK, $_, 1 << Game::getReputationLevelForPoints($this->subject->getField('reqMaxRepValue'))]);
|
||||
$minRepFac = $this->subject->getField('reqMinRepFaction');
|
||||
$maxRepFac = $this->subject->getField('reqMaxRepFaction');
|
||||
// add +/- 2 to contain edgecases. ie a reqMaxRepValue of 1 should not include the whole of REP_NEUTRAL
|
||||
$minRepRank = $minRepFac ? Game::getReputationLevelForPoints($this->subject->getField('reqMinRepValue') + 2) : REP_HATED;
|
||||
$maxRepRank = $maxRepFac ? Game::getReputationLevelForPoints($this->subject->getField('reqMaxRepValue') - 2) : REP_EXALTED;
|
||||
|
||||
$convertRankBits = function (int $minRank, int $maxRank) : int
|
||||
{
|
||||
$bits = 0;
|
||||
for ($i = $minRank; $i <= $maxRank; $i++)
|
||||
$bits |= (1 << $i);
|
||||
|
||||
return $bits;
|
||||
};
|
||||
|
||||
if ($minRepFac && $maxRepFac && $minRepFac <> $maxRepFac)
|
||||
{
|
||||
$cnd->addExternalCondition(Conditions::SRC_QUEST_AVAILABLE, '0:'.$this->typeId, [Conditions::REPUTATION_RANK, $minRepFac, $convertRankBits($minRepRank, REP_EXALTED)]);
|
||||
$cnd->addExternalCondition(Conditions::SRC_QUEST_AVAILABLE, '0:'.$this->typeId, [Conditions::REPUTATION_RANK, $maxRepFac, $convertRankBits(REP_HATED, $maxRepRank)]);
|
||||
}
|
||||
else if (($_ = $minRepFac) || ($_ = $maxRepFac))
|
||||
$cnd->addExternalCondition(Conditions::SRC_QUEST_AVAILABLE, '0:'.$this->typeId, [Conditions::REPUTATION_RANK, $_, $convertRankBits($minRepRank, $maxRepRank)]);
|
||||
|
||||
if ($tab = $cnd->toListviewTab())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -135,22 +135,16 @@ class Game
|
|||
|
||||
public static function getReputationLevelForPoints(int $pts) : int
|
||||
{
|
||||
if ($pts >= 41999)
|
||||
return REP_EXALTED;
|
||||
if ($pts >= 20999)
|
||||
return REP_REVERED;
|
||||
if ($pts >= 8999)
|
||||
return REP_HONORED;
|
||||
if ($pts >= 2999)
|
||||
return REP_FRIENDLY;
|
||||
if ($pts >= 0)
|
||||
return REP_NEUTRAL;
|
||||
if ($pts >= -3000)
|
||||
return REP_UNFRIENDLY;
|
||||
if ($pts >= -6000)
|
||||
return REP_HOSTILE;
|
||||
|
||||
return REP_HATED;
|
||||
return match (true) {
|
||||
$pts >= 42000 => REP_EXALTED,
|
||||
$pts >= 21000 => REP_REVERED,
|
||||
$pts >= 9000 => REP_HONORED,
|
||||
$pts >= 3000 => REP_FRIENDLY,
|
||||
$pts >= 0 => REP_NEUTRAL,
|
||||
$pts >= -3000 => REP_UNFRIENDLY,
|
||||
$pts >= -6000 => REP_HOSTILE,
|
||||
default => REP_HATED,
|
||||
};
|
||||
}
|
||||
|
||||
public static function getTaughtSpells(mixed &$spell) : array
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue