mirror of
https://github.com/edgegamers/Jailbreak.git
synced 2025-12-06 04:42:57 -08:00
Bump sd color price
This commit is contained in:
@@ -66,6 +66,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gangs.WardenIconPerk", "mod
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gangs.SpecialIconPerk", "mod\Gangs.SpecialIconPerk\Gangs.SpecialIconPerk.csproj", "{7F4BCD17-658C-4928-9AC1-61EFDEABDF5C}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WardenPaintColorPerk", "mod\WardenPaintColorPerk\WardenPaintColorPerk.csproj", "{71D8A1A7-EB94-485A-82CC-D2D5124FE690}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -184,6 +186,10 @@ Global
|
||||
{7F4BCD17-658C-4928-9AC1-61EFDEABDF5C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7F4BCD17-658C-4928-9AC1-61EFDEABDF5C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7F4BCD17-658C-4928-9AC1-61EFDEABDF5C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{71D8A1A7-EB94-485A-82CC-D2D5124FE690}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{71D8A1A7-EB94-485A-82CC-D2D5124FE690}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{71D8A1A7-EB94-485A-82CC-D2D5124FE690}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{71D8A1A7-EB94-485A-82CC-D2D5124FE690}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{9135CCC9-66C5-4A9C-AE3C-91475B5F0437} = {177DA48D-8306-4102-918D-992569878581}
|
||||
@@ -215,5 +221,6 @@ Global
|
||||
{978DB4AA-A4C5-4B3A-9EB6-0371DDC854C1} = {36BA84C0-291C-4930-A7C6-97CDF8F7F0D7}
|
||||
{A8947625-840F-4A87-96F3-8E8D3C6F3331} = {069A4F54-AE2A-4FDF-A5A8-F550B254C2A9}
|
||||
{7F4BCD17-658C-4928-9AC1-61EFDEABDF5C} = {069A4F54-AE2A-4FDF-A5A8-F550B254C2A9}
|
||||
{71D8A1A7-EB94-485A-82CC-D2D5124FE690} = {069A4F54-AE2A-4FDF-A5A8-F550B254C2A9}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
@@ -18,8 +18,7 @@ using Microsoft.Extensions.Localization;
|
||||
namespace Gangs.BaseImpl;
|
||||
|
||||
public abstract class AbstractEnumCommand<T>(IServiceProvider provider,
|
||||
string statId, T def, string title, bool isOnlyGang)
|
||||
: ICommand where T : struct, Enum {
|
||||
string statId, T def, string title) : ICommand where T : struct, Enum {
|
||||
private readonly ICommandManager commands =
|
||||
provider.GetRequiredService<ICommandManager>();
|
||||
|
||||
@@ -75,13 +74,8 @@ public abstract class AbstractEnumCommand<T>(IServiceProvider provider,
|
||||
if (!success) data = def;
|
||||
|
||||
T equipped;
|
||||
if (isOnlyGang) {
|
||||
var (_, tmp) = await gangStats.GetForGang<T>(player.GangId.Value, statId);
|
||||
equipped = tmp;
|
||||
} else {
|
||||
var (_, tmp) = await playerStats.GetForPlayer<T>(player.Steam, statId);
|
||||
equipped = tmp;
|
||||
}
|
||||
var (_, tmp) = await playerStats.GetForPlayer<T>(player.Steam, statId);
|
||||
equipped = tmp;
|
||||
|
||||
if (info.Args.Length == 1) {
|
||||
openMenu(executor, data, equipped);
|
||||
@@ -123,24 +117,6 @@ public abstract class AbstractEnumCommand<T>(IServiceProvider provider,
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
||||
if (isOnlyGang) {
|
||||
var (canManage, required) =
|
||||
await ranks.CheckRank(player, Perm.MANAGE_PERKS);
|
||||
if (!canManage) {
|
||||
info.ReplySync(localizer.Get(MSG.GENERIC_NOPERM_RANK, required.Name));
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
||||
Unsafe.As<T, short>(ref equipped) = Unsafe.As<T, short>(ref val);
|
||||
await gangStats.SetForGang(gang, statId, data);
|
||||
|
||||
if (gangChat == null) return CommandResult.SUCCESS;
|
||||
|
||||
await gangChat.SendGangChat(player, gang,
|
||||
localizer.Get(MSG.GANG_THING_SET, title, formatItem(val)));
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
||||
await playerStats.SetForPlayer(executor, statId, val);
|
||||
executor.PrintToChat(
|
||||
$"{localizer.Get(MSG.PREFIX)}Set your {ChatColors.BlueGrey + title}{ChatColors.Grey} to {formatItem(val)}.");
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace Gangs.LastRequestColorPerk;
|
||||
|
||||
public class LRColorCommand(IServiceProvider provider)
|
||||
: AbstractEnumCommand<LRColor>(provider, LRColorPerk.STAT_ID, LRColor.DEFAULT,
|
||||
"LR Color", false) {
|
||||
"LR Color") {
|
||||
public override string Name => "css_lrcolor";
|
||||
|
||||
override protected void openMenu(PlayerWrapper player, LRColor data,
|
||||
|
||||
@@ -19,9 +19,9 @@ public enum SDColor {
|
||||
|
||||
public static class SDColorExtensions {
|
||||
public static int GetCost(this SDColor color) {
|
||||
if (color == SDColor.RAINBOW) return 10 * 2500;
|
||||
if (color == SDColor.RAINBOW) return 10 * 5000;
|
||||
if (color == SDColor.DEFAULT) return 0;
|
||||
return (int)Math.Round(color.GetColor().GetColorMultiplier() * 2500);
|
||||
return (int)Math.Round(color.GetColor().GetColorMultiplier() * 5000);
|
||||
}
|
||||
|
||||
public static Color? GetColor(this SDColor color) {
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Gangs.SpecialIconPerk;
|
||||
|
||||
public class SpecialIconCommand(IServiceProvider provider)
|
||||
: AbstractEnumCommand<SpecialIcon>(provider, SpecialIconPerk.STAT_ID,
|
||||
SpecialIcon.DEFAULT, "ST Icon", false) {
|
||||
SpecialIcon.DEFAULT, "ST Icon") {
|
||||
public override string Name => "css_sticon";
|
||||
|
||||
override protected void openMenu(PlayerWrapper player, SpecialIcon data,
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace Gangs.WardenIconPerk;
|
||||
|
||||
public class WardenIconCommand(IServiceProvider provider)
|
||||
: AbstractEnumCommand<WardenIcon>(provider, WardenIconPerk.STAT_ID,
|
||||
WardenIcon.DEFAULT, "Warden Icon", false) {
|
||||
WardenIcon.DEFAULT, "Warden Icon") {
|
||||
public override string Name => "css_wardenicon";
|
||||
|
||||
override protected void openMenu(PlayerWrapper player, WardenIcon data,
|
||||
|
||||
@@ -11,6 +11,7 @@ using Gangs.LastRequestColorPerk;
|
||||
using GangsAPI;
|
||||
using GangsAPI.Data;
|
||||
using GangsAPI.Services;
|
||||
using GangsAPI.Services.Gang;
|
||||
using GangsAPI.Services.Player;
|
||||
using Jailbreak.Formatting.Extensions;
|
||||
using Jailbreak.Formatting.Views.LastRequest;
|
||||
@@ -229,8 +230,12 @@ public class LastRequestManager(ILRLocale messages, IServiceProvider provider)
|
||||
|
||||
private async Task colorForLR(PlayerWrapper a, PlayerWrapper b) {
|
||||
var playerStats = API.Gangs?.Services.GetService<IPlayerStatManager>();
|
||||
var gangStats = API.Gangs?.Services.GetService<IGangStatManager>();
|
||||
var gangs = API.Gangs?.Services.GetService<IGangManager>();
|
||||
var localizer = API.Gangs?.Services.GetService<IStringLocalizer>();
|
||||
if (playerStats == null || localizer == null) return;
|
||||
if (playerStats == null || localizer == null || gangs == null
|
||||
|| gangStats == null)
|
||||
return;
|
||||
var (aSuccess, aData) =
|
||||
await playerStats.GetForPlayer<LRColor>(a, LRColorPerk.STAT_ID);
|
||||
var (bSuccess, bData) =
|
||||
@@ -255,14 +260,21 @@ public class LastRequestManager(ILRLocale messages, IServiceProvider provider)
|
||||
if (toApply == null || higher == null) return;
|
||||
if (a.Player == null || b.Player == null) return;
|
||||
|
||||
var higherGang = await gangs.GetGang(higher.Steam);
|
||||
if (higherGang == null) return;
|
||||
|
||||
var (gangSuccess, gData) =
|
||||
await gangStats.GetForGang<LRColor>(higherGang, LRColorPerk.STAT_ID);
|
||||
|
||||
if (!gangSuccess) return;
|
||||
if ((gData & toApply.Value) == 0) return;
|
||||
|
||||
var color = toApply.Value.GetColor();
|
||||
|
||||
if (color == null) { // Player picked random, but we need to pick
|
||||
// the random from their GANG's colors
|
||||
var gangStats = API.Gangs?.Services.GetService<IPlayerStatManager>();
|
||||
if (gangStats == null) return;
|
||||
var (success, gangData) =
|
||||
await gangStats.GetForPlayer<LRColor>(higher, LRColorPerk.STAT_ID);
|
||||
await playerStats.GetForPlayer<LRColor>(higher, LRColorPerk.STAT_ID);
|
||||
if (!success) return;
|
||||
color = gangData.PickRandomColor();
|
||||
}
|
||||
|
||||
@@ -34,14 +34,15 @@ public class SpecialIconBehavior(ITextSpawner spawner)
|
||||
|
||||
if (!success) icon = SpecialIcon.DEFAULT;
|
||||
|
||||
if (icon != SpecialIcon.RANDOM || gangStats == null || players == null)
|
||||
return icon.GetIcon();
|
||||
if (gangStats == null || players == null) return icon.GetIcon();
|
||||
|
||||
var gangPlayer = await players.GetPlayer(player.Steam);
|
||||
if (gangPlayer?.GangId == null) return SpecialIcon.DEFAULT.GetIcon();
|
||||
var (_, available) =
|
||||
await gangStats.GetForGang<SpecialIcon>(gangPlayer.GangId.Value,
|
||||
SpecialIconPerk.STAT_ID);
|
||||
return available.PickRandom();
|
||||
|
||||
if ((available & icon) == 0) return SpecialIcon.DEFAULT.GetIcon();
|
||||
return icon != SpecialIcon.RANDOM ? icon.GetIcon() : available.PickRandom();
|
||||
}
|
||||
}
|
||||
@@ -34,14 +34,15 @@ public class WardenIconBehavior(ITextSpawner spawner)
|
||||
|
||||
if (!success) icon = WardenIcon.DEFAULT;
|
||||
|
||||
if (icon != WardenIcon.RANDOM || gangStats == null || players == null)
|
||||
return icon.GetIcon();
|
||||
if (gangStats == null || players == null) return icon.GetIcon();
|
||||
|
||||
var gangPlayer = await players.GetPlayer(player.Steam);
|
||||
if (gangPlayer?.GangId == null) return WardenIcon.DEFAULT.GetIcon();
|
||||
var (_, available) =
|
||||
await gangStats.GetForGang<WardenIcon>(gangPlayer.GangId.Value,
|
||||
WardenIconPerk.STAT_ID);
|
||||
return available.PickRandom();
|
||||
|
||||
if ((available & icon) == 0) return WardenIcon.DEFAULT.GetIcon();
|
||||
return icon != WardenIcon.RANDOM ? icon.GetIcon() : available.PickRandom();
|
||||
}
|
||||
}
|
||||
5
mod/WardenPaintColorPerk/WardenColorBootstrap.cs
Normal file
5
mod/WardenPaintColorPerk/WardenColorBootstrap.cs
Normal file
@@ -0,0 +1,5 @@
|
||||
namespace WardenPaintColorPerk;
|
||||
|
||||
public class WardenColorBootstrap {
|
||||
|
||||
}
|
||||
28
mod/WardenPaintColorPerk/WardenColorCommand.cs
Normal file
28
mod/WardenPaintColorPerk/WardenColorCommand.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using Gangs.BaseImpl;
|
||||
using Gangs.BaseImpl.Extensions;
|
||||
using GangsAPI.Data;
|
||||
using Jailbreak.Public.Extensions;
|
||||
using Jailbreak.Public.Mod.Rainbow;
|
||||
|
||||
namespace WardenPaintColorPerk;
|
||||
|
||||
public class WardenColorCommand(IServiceProvider provider)
|
||||
: AbstractEnumCommand<WardenPaintColor>(provider,
|
||||
WardenPaintColorPerk.STAT_ID, WardenPaintColor.DEFAULT, "Paint Color") {
|
||||
public override string Name => "css_paint";
|
||||
|
||||
override protected void openMenu(PlayerWrapper player, WardenPaintColor data,
|
||||
WardenPaintColor equipped) {
|
||||
var menu = new WardenPaintColorMenu(Provider, data, equipped);
|
||||
Menus.OpenMenu(player, menu);
|
||||
}
|
||||
|
||||
override protected int getCost(WardenPaintColor item) {
|
||||
return item.GetCost();
|
||||
}
|
||||
|
||||
override protected string formatItem(WardenPaintColor item) {
|
||||
if (item == WardenPaintColor.RAINBOW) return IRainbowColorizer.RAINBOW;
|
||||
return $"{item.GetColor().GetChatColor()}{item.ToString().ToTitleCase()}";
|
||||
}
|
||||
}
|
||||
24
mod/WardenPaintColorPerk/WardenPaintColorMenu.cs
Normal file
24
mod/WardenPaintColorPerk/WardenPaintColorMenu.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using Gangs.BaseImpl;
|
||||
using Gangs.BaseImpl.Extensions;
|
||||
using Jailbreak.Public.Extensions;
|
||||
using Jailbreak.Public.Mod.Rainbow;
|
||||
|
||||
namespace WardenPaintColorPerk;
|
||||
|
||||
public class WardenPaintColorMenu(IServiceProvider provider,
|
||||
WardenPaintColor data, WardenPaintColor equipped)
|
||||
: AbstractEnumMenu<WardenPaintColor>(provider, data, equipped, "css_paint",
|
||||
"Paint Color", WardenPaintColorPerk.DESC) {
|
||||
override protected int getCost(WardenPaintColor item) {
|
||||
return item.GetCost();
|
||||
}
|
||||
|
||||
override protected List<WardenPaintColor> getValues() {
|
||||
return Enum.GetValues<WardenPaintColor>().ToList();
|
||||
}
|
||||
|
||||
override protected string formatItem(WardenPaintColor item) {
|
||||
if (item == WardenPaintColor.RAINBOW) return IRainbowColorizer.RAINBOW;
|
||||
return $"{item.GetColor().GetChatColor()}{item.ToString().ToTitleCase()}";
|
||||
}
|
||||
}
|
||||
46
mod/WardenPaintColorPerk/WardenPaintColorPerk.cs
Normal file
46
mod/WardenPaintColorPerk/WardenPaintColorPerk.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using System.Diagnostics;
|
||||
using Gangs.BaseImpl;
|
||||
using GangsAPI.Data.Gang;
|
||||
using GangsAPI.Services.Gang;
|
||||
using GangsAPI.Services.Menu;
|
||||
using GangsAPI.Services.Player;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace WardenPaintColorPerk;
|
||||
|
||||
public class WardenPaintColorPerk(IServiceProvider provider)
|
||||
: BasePerk<WardenPaintColor>(provider) {
|
||||
private readonly IGangStatManager gangStats =
|
||||
provider.GetRequiredService<IGangStatManager>();
|
||||
|
||||
private readonly IPlayerStatManager playerStats =
|
||||
provider.GetRequiredService<IPlayerStatManager>();
|
||||
|
||||
public const string STAT_ID = "jb_wardenpaintcolor";
|
||||
public const string DESC = "Change the color of your warden paint!";
|
||||
|
||||
public override string StatId => STAT_ID;
|
||||
public override string Name => "Paint Color";
|
||||
public override string? Description => DESC;
|
||||
|
||||
public override Task<int?> GetCost(IGangPlayer player) {
|
||||
return Task.FromResult<int?>(null);
|
||||
}
|
||||
|
||||
public override Task OnPurchase(IGangPlayer player) {
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public override async Task<IMenu?> GetMenu(IGangPlayer player) {
|
||||
Debug.Assert(player.GangId != null, "player.GangId != null");
|
||||
var (success, data) =
|
||||
await gangStats.GetForGang<WardenPaintColor>(player.GangId.Value,
|
||||
STAT_ID);
|
||||
if (!success) data = WardenPaintColor.DEFAULT;
|
||||
var (_, equipped) =
|
||||
await playerStats.GetForPlayer<WardenPaintColor>(player.Steam, STAT_ID);
|
||||
return new WardenPaintColorMenu(Provider, data, equipped);
|
||||
}
|
||||
|
||||
public override WardenPaintColor Value { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user