Peacock/components/types/score.ts

188 lines
5.2 KiB
TypeScript
Raw Normal View History

/*
* The Peacock Project - a HITMAN server replacement.
* Copyright (C) 2021-2024 The Peacock Project Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { Playstyle, ScoringBonus, ScoringHeadline } from "./scoring"
import {
ChallengeCompletion,
CompletionData,
OpportunityStatistics,
Seconds,
Unlockable,
} from "./types"
export interface CalculateXpResult {
completedChallenges: MissionEndChallenge[]
xp: number
}
export interface CalculateScoreResult {
stars: number
scoringHeadlines: ScoringHeadline[]
awardedBonuses: ScoringBonus[]
failedBonuses: ScoringBonus[]
achievedMasteries: MissionEndAchievedMastery[]
silentAssassin: boolean
score: number
scoreWithBonus: number
}
Multi-Version Mastery and Sniper Scoring (#270) * Add multi-version mastery files * Add pro1 unlocks to legacy allunlockables * Add 47's suit to scpc all unlockables * Add and remove various configs * Remove some useless promises * Fix scpc hub * Fix issue with user profile saving * Fix scpc issues for hub * Add singleplayer/multiplayer sniper * A great many things - Add multi-version mastery - Improve sniper mastery support - Improve general H2016 support * Fix some warnings * Fix pro1 mastery on destination screens * Remove entP from createInventory, lock/unlock pro1 accordingly * Remove JSDoc entP parameter from createInventory * Remove difficultyunlocks from safehouse pages * Add versioned user profiles * Prettier run * Remove false point from user profiles docs * Add comment about profile versioning to types * Fix default profile links * Remove remaining lowercase * Fix sniper showing XP as XP * Add game versions to the unlockable map * Update getMasteryForUnlockable call in planning * Fix missing locations when updating profiles * Update versions to v7 * Fix ICA Facility destination mastery * Fix sniper challenge unlockables showing in inventory * Sniper Scoring (#273) * Initial sniper scoring * Fix linting errors * Update require table * Calculate and display final sniper score on end screen * Bump SMP version to v5.7.0 * Update since version for scoring * Fix create inventory call for sniper scoring * Support sniper unlockables in the inventory * Update versions to v7 * Reflect changes to createInventory in scoreHandler * Get unlockable name in completion data * It was not okay. * Thanks webstorm * Add support for /profiles/page/GetMasteryCompletionDataForUnlockable * Support sniper play next * Remove sniper gamemodes template from overrides * Remove debug prints from scoring event handler * Fix challenge multiplier * Exclude sniper unlockables from stashpoint * Start fixing up the missionEnd response for sniper * Update misleading comment * Use existing global challenge to check for SA on sniper contracts * Re-add removed global challenges * Proper support for the mission end screen on sniper contracts * Remove redundant label --------- Signed-off-by: Anthony Fuller <24512050+AnthonyFuller@users.noreply.github.com> Co-authored-by: Govert de Gans <grappigegovert@hotmail.com> * Add co-op sniper scoring defs * Update MasteryUnlockable template * Bump SMP version to v5.9.3 * Re-add deepmerge * Fix SMP checksum * Fix linting errors caused by merge * Fix score handler imports * Move load flags * Remove unnecessary game version arg * Whoopsies Co-authored-by: Reece Dunham <me@rdil.rocks> Signed-off-by: Anthony Fuller <24512050+AnthonyFuller@users.noreply.github.com> --------- Signed-off-by: Anthony Fuller <24512050+AnthonyFuller@users.noreply.github.com> Co-authored-by: Govert de Gans <grappigegovert@hotmail.com> Co-authored-by: Reece Dunham <me@rdil.rocks>
2023-07-25 00:47:28 +02:00
export interface CalculateSniperScoreResult {
FinalScore: number
BaseScore: number
TotalChallengeMultiplier: number
BulletsMissed: number
BulletsMissedPenalty: number
TimeTaken: number
TimeBonus: number
SilentAssassin: boolean
SilentAssassinBonus: number
SilentAssassinMultiplier: number
}
export interface MissionEndChallenge {
ChallengeId: string
ChallengeTags: string[]
ChallengeName: string
ChallengeImageUrl: string
ChallengeDescription: string
XPGain: number
IsGlobal: boolean
IsActionReward: boolean
2023-11-27 18:56:32 +01:00
Drops?: string[]
}
feat: initial support for mastery progression (#161) * feat: Initial support for mastery progression * chore: Fix typo * feat: Award users challenge drops immediately after completion. Also builds the inventory on startup with those drops * feat: Award mastery unlockables to user as soon as they are available * feat: Added flag to toggle mastery progression * fix: Address linting issues * feat: Handle loadout lock for Miami and Hokkaido * fix: Looking for LimitedSlots on parent location, to include all contracts on the location * Update components/flags.ts Co-authored-by: Reece Dunham <me@rdil.rocks> Signed-off-by: J0k3r-1 <128742169+J0k3r-1@users.noreply.github.com> * refactor: Look at location LimitedLoadout to prevent unecessary unlockable lookups * refactor: Add a different Map for mapping Level and Location to an unlockable id * fix: Prevent evergreen gear unlockables to be awarded to the user inventory w/t proper mastery level Evergreen level unlockables for gear are treated the same as packages, and include the actual unlockable item within their properties, so similar logic to packages was needed to address those correctly * refactor: Use gameVersion from contractSession on grantLocationMasteryXp * fix: Fix typo * feat: Add progression service to handle XP and Drop award (#1) * refactor: Cleanup unused imports * refactor: Added some improvments over feedback * fix: Fix wrong evergreen check flag condition * feat: Added challenge drops to missionEnd screen + minor fixes * refactor: Removed writeUserData from challengeService The progressionService already stores the data, so theres no need to call it again here * fix: Prevent evergreenmastery unlock types from being awarded to the inventory * chore: Amend the explanation for getLocationMasteryDrops on evergreen type unlock * Update components/menus/planning.ts Co-authored-by: moonysolari <118079569+moonysolari@users.noreply.github.com> Signed-off-by: J0k3r-1 <128742169+J0k3r-1@users.noreply.github.com> * refactor: Award evergreenmastery but filter on inventory grant, like createInventory * refactor: Refactor challenge drop usage as they have been refactored from Unlockable[] to string[] * fix: Add mastery requirement for locked loadouts on Miami and Hokkaido + Add interface for sourcechallenge * chore: Remove console.log * fix: fixed H1 hokkaido not starting --------- Signed-off-by: J0k3r-1 <128742169+J0k3r-1@users.noreply.github.com> Co-authored-by: Reece Dunham <me@rdil.rocks> Co-authored-by: moonysolari <118079569+moonysolari@users.noreply.github.com>
2023-04-05 21:19:28 +02:00
export interface MissionEndSourceChallenge {
ChallengeId: string
ChallengeTags: string[]
ChallengeName: string
ChallengeImageUrl: string
ChallengeDescription: string
XPGain: number
IsGlobal: boolean
IsActionReward: boolean
}
export interface MissionEndDrop {
Unlockable: Unlockable
feat: initial support for mastery progression (#161) * feat: Initial support for mastery progression * chore: Fix typo * feat: Award users challenge drops immediately after completion. Also builds the inventory on startup with those drops * feat: Award mastery unlockables to user as soon as they are available * feat: Added flag to toggle mastery progression * fix: Address linting issues * feat: Handle loadout lock for Miami and Hokkaido * fix: Looking for LimitedSlots on parent location, to include all contracts on the location * Update components/flags.ts Co-authored-by: Reece Dunham <me@rdil.rocks> Signed-off-by: J0k3r-1 <128742169+J0k3r-1@users.noreply.github.com> * refactor: Look at location LimitedLoadout to prevent unecessary unlockable lookups * refactor: Add a different Map for mapping Level and Location to an unlockable id * fix: Prevent evergreen gear unlockables to be awarded to the user inventory w/t proper mastery level Evergreen level unlockables for gear are treated the same as packages, and include the actual unlockable item within their properties, so similar logic to packages was needed to address those correctly * refactor: Use gameVersion from contractSession on grantLocationMasteryXp * fix: Fix typo * feat: Add progression service to handle XP and Drop award (#1) * refactor: Cleanup unused imports * refactor: Added some improvments over feedback * fix: Fix wrong evergreen check flag condition * feat: Added challenge drops to missionEnd screen + minor fixes * refactor: Removed writeUserData from challengeService The progressionService already stores the data, so theres no need to call it again here * fix: Prevent evergreenmastery unlock types from being awarded to the inventory * chore: Amend the explanation for getLocationMasteryDrops on evergreen type unlock * Update components/menus/planning.ts Co-authored-by: moonysolari <118079569+moonysolari@users.noreply.github.com> Signed-off-by: J0k3r-1 <128742169+J0k3r-1@users.noreply.github.com> * refactor: Award evergreenmastery but filter on inventory grant, like createInventory * refactor: Refactor challenge drop usage as they have been refactored from Unlockable[] to string[] * fix: Add mastery requirement for locked loadouts on Miami and Hokkaido + Add interface for sourcechallenge * chore: Remove console.log * fix: fixed H1 hokkaido not starting --------- Signed-off-by: J0k3r-1 <128742169+J0k3r-1@users.noreply.github.com> Co-authored-by: Reece Dunham <me@rdil.rocks> Co-authored-by: moonysolari <118079569+moonysolari@users.noreply.github.com>
2023-04-05 21:19:28 +02:00
SourceChallenge?: MissionEndSourceChallenge
}
export interface MissionEndAchievedMastery {
score: number
RatioParts: number
RatioTotal: number
Id: string
BaseScore: number
}
export interface MissionEndEvergreen {
Payout: number
EndStateEventName?: string
PayoutsCompleted: MissionEndEvergreenPayout[]
PayoutsFailed: MissionEndEvergreenPayout[]
}
export interface MissionEndEvergreenPayout {
Name: string
Payout: number
IsPrestige: boolean
}
export interface MissionEndResult {
MissionReward: {
LocationProgression: {
LevelInfo: number[]
XP: number
Level: number
Completion: number
XPGain: number
HideProgression: boolean
}
ProfileProgression: {
LevelInfo: number[]
LevelInfoOffset: number
XP: number
Level: number
XPGain: number
}
Challenges: MissionEndChallenge[]
Drops: MissionEndDrop[]
OpportunityRewards: unknown[] // ?
UnlockableProgression?: {
LevelInfo: number[]
XP: number
Level: number
XPGain: number
Id: string
Name: string
}
CompletionData: CompletionData
ChallengeCompletion: ChallengeCompletion
ContractChallengeCompletion: ChallengeCompletion
OpportunityStatistics: OpportunityStatistics
LocationCompletionPercent: number
}
ScoreOverview: {
XP: number
Level: number
Completion: number
XPGain: number
ChallengesCompleted: number
LocationHideProgression: boolean
ProdileId1?: string
stars?: number
ScoreDetails: {
Headlines: ScoringHeadline[]
}
ContractScore?: {
Total: number
AchievedMasteries: MissionEndAchievedMastery[]
AwardedBonuses: ScoringBonus[]
TotalNoMultipliers: number
TimeUsedSecs: Seconds
StarCount: number
FailedBonuses: ScoringBonus[]
SilentAssassin: boolean
}
SniperChallengeScore?: {
FinalScore: number
BaseScore: number
TotalChallengeMultiplier: number
BulletsMissed: number
BulletsMissedPenalty: number
TimeTaken: number
TimeBonus: number
SilentAssassin: boolean
SilentAssassinBonus: number
SilentAssassinMultiplier: number
}
SilentAssassin: boolean
NewRank: number
RankCount: number
Rank: number
FriendsRankCount: number
FriendsRank: number
IsPartOfTopScores: boolean
PlayStyle?: Playstyle
IsNewBestScore: boolean
IsNewBestTime: boolean
IsNewBestStars: boolean
Evergreen?: MissionEndEvergreen
}
}