Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Razor.TagHelpers;
using OpenSkillSharp.Models;
using OpenSkillSharp.Rating;
using osu.Game.Online.Multiplayer;
Expand Down Expand Up @@ -336,17 +337,18 @@
/// <param name="userId">The user ID of the player taking damage.</param>
/// <param name="amount">The amount of damage (before any multipliers are added) to take.</param>
/// <returns>A descriptor for the damage taken.</returns>
public RankedPlayDamageInfo Damage(int userId, int amount)
public RankedPlayDamageInfo Damage(int attackingUserId, int recievingUserId, int amount)
{
RankedPlayUserInfo userInfo = State.Users[userId];
RankedPlayUserInfo recievingUserInfo = State.Users[recievingUserId];
RankedPlayUserInfo attackingUserInfo = State.Users[attackingUserId];

int rawDamage = amount;
int damage = (int)Math.Ceiling(rawDamage * State.DamageMultiplier);
int damage = (int)Math.Ceiling(rawDamage * State.GlobalMultiplier * attackingUserInfo.PersonalMultiplier);

Check failure on line 346 in osu.Server.Spectator/Hubs/Multiplayer/Matchmaking/RankedPlay/RankedPlayMatchController.cs

View workflow job for this annotation

GitHub Actions / Unit testing

'RankedPlayUserInfo' does not contain a definition for 'PersonalMultiplier' and no accessible extension method 'PersonalMultiplier' accepting a first argument of type 'RankedPlayUserInfo' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 346 in osu.Server.Spectator/Hubs/Multiplayer/Matchmaking/RankedPlay/RankedPlayMatchController.cs

View workflow job for this annotation

GitHub Actions / Unit testing

'RankedPlayRoomState' does not contain a definition for 'GlobalMultiplier' and no accessible extension method 'GlobalMultiplier' accepting a first argument of type 'RankedPlayRoomState' could be found (are you missing a using directive or an assembly reference?)

int oldLife = userInfo.Life;
int oldLife = recievingUserInfo.Life;
int newLife = Math.Max(0, oldLife - damage);

userInfo.Life = newLife;
recievingUserInfo.Life = newLife;

return new RankedPlayDamageInfo
{
Expand Down Expand Up @@ -447,5 +449,10 @@
{
room_type = database_match_type.ranked_play
};

/// <summary>
/// Retrieves the personal multiplier for a given player.
/// </summary>
/// <param name="winstreak">The winstreak of the given player.</param>
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Game.Online.Multiplayer;
using osu.Game.Online.Multiplayer.MatchTypes.RankedPlay;
using osu.Server.Spectator.Database.Models;
Expand Down Expand Up @@ -59,18 +60,30 @@
if (scores.All(s => s.user_id != userId))
scores.Add(new SoloScore { user_id = (uint)userId });
}

SoloScore attackingScore = scores.MaxBy(s => s.total_score)!;
SoloScore[] winningScores = scores.Where(u => u.total_score == (int)attackingScore.total_score).ToArray();
SoloScore[] losingScores = scores.Where(u => u.total_score < (int)attackingScore.total_score).ToArray();
if (winningScores.Length == 1){
State.Users[(int)winningScores.Single().user_id].RoundsWon += 1;
State.Users[(int)winningScores.Single().user_id].WinStreak += 1;

Check failure on line 69 in osu.Server.Spectator/Hubs/Multiplayer/Matchmaking/RankedPlay/Stages/ResultsStage.cs

View workflow job for this annotation

GitHub Actions / Unit testing

'RankedPlayUserInfo' does not contain a definition for 'WinStreak' and no accessible extension method 'WinStreak' accepting a first argument of type 'RankedPlayUserInfo' could be found (are you missing a using directive or an assembly reference?)
}
if (winningScores.Length >= 2) //super rare tie, it matters in winstreak so I need to account for it, this implementation is a double winstreak reset, can be changed later
{
State.Users[(int)winningScores.Single().user_id].WinStreak = 0;

Check failure on line 73 in osu.Server.Spectator/Hubs/Multiplayer/Matchmaking/RankedPlay/Stages/ResultsStage.cs

View workflow job for this annotation

GitHub Actions / Unit testing

'RankedPlayUserInfo' does not contain a definition for 'WinStreak' and no accessible extension method 'WinStreak' accepting a first argument of type 'RankedPlayUserInfo' could be found (are you missing a using directive or an assembly reference?)
}

if (losingScores.Length == 1)
State.Users[(int)losingScores.Single().user_id].WinStreak = 0; //WinStreak reset on lose

Check failure on line 77 in osu.Server.Spectator/Hubs/Multiplayer/Matchmaking/RankedPlay/Stages/ResultsStage.cs

View workflow job for this annotation

GitHub Actions / Unit testing

'RankedPlayUserInfo' does not contain a definition for 'WinStreak' and no accessible extension method 'WinStreak' accepting a first argument of type 'RankedPlayUserInfo' could be found (are you missing a using directive or an assembly reference?)

int maxTotalScore = (int)scores.Select(s => s.total_score).Max();
State.Users.ForEach(u=>u.Value.PersonalMultiplier = computePersonalMultiplier(u.Value.WinStreak));

Check failure on line 79 in osu.Server.Spectator/Hubs/Multiplayer/Matchmaking/RankedPlay/Stages/ResultsStage.cs

View workflow job for this annotation

GitHub Actions / Unit testing

'RankedPlayUserInfo' does not contain a definition for 'WinStreak' and no accessible extension method 'WinStreak' accepting a first argument of type 'RankedPlayUserInfo' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 79 in osu.Server.Spectator/Hubs/Multiplayer/Matchmaking/RankedPlay/Stages/ResultsStage.cs

View workflow job for this annotation

GitHub Actions / Unit testing

'RankedPlayUserInfo' does not contain a definition for 'PersonalMultiplier' and no accessible extension method 'PersonalMultiplier' accepting a first argument of type 'RankedPlayUserInfo' could be found (are you missing a using directive or an assembly reference?)

foreach (var score in scores)
{
var userInfo = State.Users[(int)score.user_id];
userInfo.DamageInfo = Controller.Damage((int)score.user_id, maxTotalScore - (int)score.total_score);
userInfo.DamageInfo = Controller.Damage((int)attackingScore.user_id,(int)score.user_id, (int)attackingScore.total_score - (int)score.total_score);
}

SoloScore[] winningScores = scores.Where(u => u.total_score == maxTotalScore).ToArray();
if (winningScores.Length == 1)
State.Users[(int)winningScores.Single().user_id].RoundsWon += 1;

if (Controller.Ranked)
{
Expand Down Expand Up @@ -105,5 +118,10 @@

// Remain in the results stage, which will naturally transition to the ended stage once the countdown expires.
}

private double computePersonalMultiplier(int winstreak)
{
return 1+0.5*winstreak;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Game.Online.Multiplayer;
using osu.Game.Online.Multiplayer.MatchTypes.RankedPlay;

Expand All @@ -29,7 +30,7 @@
}

State.CurrentRound++;
State.DamageMultiplier = computeDamageMultiplier(State.CurrentRound);
State.GlobalMultiplier = computeGlobalMultiplier(State.CurrentRound);

Check failure on line 33 in osu.Server.Spectator/Hubs/Multiplayer/Matchmaking/RankedPlay/Stages/RoundWarmupStage.cs

View workflow job for this annotation

GitHub Actions / Unit testing

'RankedPlayRoomState' does not contain a definition for 'GlobalMultiplier' and no accessible extension method 'GlobalMultiplier' accepting a first argument of type 'RankedPlayRoomState' could be found (are you missing a using directive or an assembly reference?)

// Activate the next player.
// For the first round, this is set during room initialisation.
Expand All @@ -50,10 +51,10 @@
}

/// <summary>
/// Retrieves the damage multiplier for a given round.
/// Retrieves the global multiplier for a given round.
/// </summary>
/// <param name="round">The round.</param>
private double computeDamageMultiplier(int round)
private double computeGlobalMultiplier(int round)
{
switch (Controller.Pool.ruleset_id)
{
Expand Down
Loading