Fix rate adjust mods not working in multi when freemod is active
This commit is contained in:
parent
c3b24d32af
commit
25105537ea
3 changed files with 55 additions and 3 deletions
|
@ -32,4 +32,8 @@ export function isNullOrEmpty(str:string | undefined | null) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function enumHasFlag(value:number, flag:number) : boolean {
|
||||||
|
return (value & flag) === flag;
|
||||||
}
|
}
|
|
@ -1,4 +1,33 @@
|
||||||
// TODO: Mods enum
|
// TODO: Complete mods enum.
|
||||||
export enum Mods {
|
export enum Mods {
|
||||||
None
|
None,
|
||||||
|
NoFail = 1 << 0,
|
||||||
|
Easy = 1 << 1,
|
||||||
|
// 2 was used for the "No Video" mod but that's gone now.
|
||||||
|
Hidden = 1 << 3,
|
||||||
|
HardRock = 1 << 4,
|
||||||
|
SuddenDeath = 1 << 5,
|
||||||
|
DoubleTime = 1 << 6,
|
||||||
|
Relax = 1 << 7,
|
||||||
|
HalfTime = 1 << 8,
|
||||||
|
Nightcore = 1 << 9,
|
||||||
|
Flashlight = 1 << 10,
|
||||||
|
Autoplay = 1 << 11,
|
||||||
|
SpunOut = 1 << 12,
|
||||||
|
Autopilot = 1 << 13, // I think this is autopilot???
|
||||||
|
Perfect = 1 << 14,
|
||||||
|
Mania4K = 1 << 15,
|
||||||
|
Mania5K = 1 << 16,
|
||||||
|
Mania6K = 1 << 17,
|
||||||
|
Mania7K = 1 << 18,
|
||||||
|
Mania8K = 1 << 19,
|
||||||
|
FadeIn = 1 << 20,
|
||||||
|
Random = 1 << 21,
|
||||||
|
Cinema = 1 << 22,
|
||||||
|
Target = 1 << 23,
|
||||||
|
Mania9K = 1 << 24,
|
||||||
|
ManiaCoop = 1 << 25,
|
||||||
|
Mania1K = 1 << 26,
|
||||||
|
Mania3K = 1 << 27,
|
||||||
|
Mania2K = 1 << 28
|
||||||
}
|
}
|
|
@ -11,8 +11,14 @@ import MatchStartSkipData from "../interfaces/MatchStartSkipData";
|
||||||
import { Mods } from "../enums/Mods";
|
import { Mods } from "../enums/Mods";
|
||||||
import PlayerScore from "../interfaces/PlayerScore";
|
import PlayerScore from "../interfaces/PlayerScore";
|
||||||
import MatchScoreData from "../interfaces/MatchScoreData";
|
import MatchScoreData from "../interfaces/MatchScoreData";
|
||||||
|
import { enumHasFlag } from "../Util";
|
||||||
import osu from "../../osuTyping";
|
import osu from "../../osuTyping";
|
||||||
|
|
||||||
|
// Mods which need to be applied to the match during freemod.
|
||||||
|
const matchFreemodGlobalMods:Array<Mods> = [
|
||||||
|
Mods.DoubleTime, Mods.Nightcore, Mods.HalfTime
|
||||||
|
]
|
||||||
|
|
||||||
export default class Match {
|
export default class Match {
|
||||||
// osu! Data
|
// osu! Data
|
||||||
public matchId:number = -1;
|
public matchId:number = -1;
|
||||||
|
@ -431,6 +437,19 @@ export default class Match {
|
||||||
if (this.specialModes === 1) {
|
if (this.specialModes === 1) {
|
||||||
slot.mods = mods;
|
slot.mods = mods;
|
||||||
|
|
||||||
|
// Extra check for host during freemod
|
||||||
|
if (User.Equals(this.host, user)) {
|
||||||
|
let generatedMatchModList = 0;
|
||||||
|
for (const mod of matchFreemodGlobalMods) {
|
||||||
|
if (enumHasFlag(slot.mods, mod)) {
|
||||||
|
slot.mods -= mod;
|
||||||
|
generatedMatchModList += mod;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.activeMods = generatedMatchModList;
|
||||||
|
}
|
||||||
|
|
||||||
this.sendMatchUpdate();
|
this.sendMatchUpdate();
|
||||||
} else {
|
} else {
|
||||||
if (!User.Equals(this.host, user)) {
|
if (!User.Equals(this.host, user)) {
|
||||||
|
@ -632,7 +651,7 @@ export default class Match {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
matchScoreData.id = user.id;
|
matchScoreData.id = user.matchSlot.slotId;
|
||||||
|
|
||||||
// Update playerScores
|
// Update playerScores
|
||||||
for (const playerScore of this.playerScores) {
|
for (const playerScore of this.playerScores) {
|
||||||
|
|
Loading…
Reference in a new issue