Skip to content

Commit

Permalink
ZS: Allow configuring reward money
Browse files Browse the repository at this point in the history
  • Loading branch information
UnknownShadow200 committed Jan 19, 2023
1 parent 1bf8213 commit 4cd7f55
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 12 deletions.
4 changes: 2 additions & 2 deletions MCGalaxy/Database/IDatabaseBackend.cs
Expand Up @@ -184,8 +184,8 @@ record => values.Add(record.GetText(0)),
}


/// <summary> Adds IDbDataParameter for each argument to the given command. </summary>
public void FillParams(ISqlCommand cmd, object[] parameters) {
/// <summary> Sets the SQL command's parameter values to the given arguments </summary>
public static void FillParams(ISqlCommand cmd, object[] parameters) {
if (parameters == null || parameters.Length == 0) return;

string[] names = GetNames(parameters.Length);
Expand Down
3 changes: 1 addition & 2 deletions MCGalaxy/Database/SqlTransaction.cs
Expand Up @@ -62,10 +62,9 @@ public sealed class SqlTransaction : IDisposable
}

public bool Execute(string sql, params object[] args) {
IDatabaseBackend db = Database.Backend;
try {
using (ISqlCommand cmd = conn.CreateCommand(sql)) {
db.FillParams(cmd, args);
IDatabaseBackend.FillParams(cmd, args);
cmd.ExecuteNonQuery();
return true;
}
Expand Down
6 changes: 4 additions & 2 deletions MCGalaxy/Games/RoundsGame/LevelPicker.cs
Expand Up @@ -102,7 +102,8 @@ public class LevelPicker
void VoteCountdown(IGame game) {
// Show message for non-CPE clients
Player[] players = PlayerInfo.Online.Items;
foreach (Player pl in players) {
foreach (Player pl in players)
{
if (pl.level != game.Map || pl.Supports(CpeExt.MessageTypes)) continue;
pl.Message("You have " + VoteTime + " seconds to vote for the next map");
}
Expand All @@ -112,7 +113,8 @@ public class LevelPicker
players = PlayerInfo.Online.Items;
if (!game.Running) break;

foreach (Player pl in players) {
foreach (Player pl in players)
{
if (pl.level != map || !pl.Supports(CpeExt.MessageTypes)) continue;
string timeLeft = "&e" + (VoteTime - i) + "s &Sleft to vote";
pl.SendCpeMessage(CpeMessageType.BottomRight1, timeLeft);
Expand Down
2 changes: 1 addition & 1 deletion MCGalaxy/Modules/Games/LavaSurvival/LSConfig.cs
Expand Up @@ -30,7 +30,7 @@ public sealed class LSConfig : RoundsGameConfig
[ConfigInt("below-sealevel-reward-min", "Rewards", 5, 0)]
public int BSL_RewardMin = 5;
[ConfigInt("below-sealevel-reward-max", "Rewards", 10, 0)]
public int BSL_RewardMax = 10;
public int BSL_RewardMax = 10;
[ConfigInt("above-sealevel-reward-min", "Rewards", 10, 0)]
public int ASL_RewardMin = 10;
[ConfigInt("above-sealevel-reward-max", "Rewards", 15, 0)]
Expand Down
16 changes: 16 additions & 0 deletions MCGalaxy/Modules/Games/ZombieSurvival/ZSConfig.cs
Expand Up @@ -75,6 +75,22 @@ public sealed class ZSConfig : RoundsGameConfig
[ConfigInt("revive-times", "Revive", 1, 0)]
public int ReviveTimes = 1;

[ConfigInt("zombies-win-reward-min", "Zombie rewards", 1, 0)]
public int ZombiesRewardMin = 1;
[ConfigInt("zombies-win-reward-max", "Zombie rewards", 5, 0)]
public int ZombiesRewardMax = 5;
[ConfigInt("zombies-win-infected-multiplier", "Zombie rewards", 1, 0)]
public int ZombiesRewardMultiplier = 1;

[ConfigInt("sole-human-reward-min", "Human rewards", 5, 0)]
public int SoleHumanRewardMin = 5;
[ConfigInt("sole-human-reward-max", "Human rewards", 10, 0)]
public int SoleHumanRewardMax = 10;
[ConfigInt("humans-win-reward-min", "Human rewards", 2, 0)]
public int HumansRewardMin = 2;
[ConfigInt("humans-win-reward-max", "Human rewards", 6, 0)]
public int HumansRewardMax = 6;

static ConfigElement[] cfg;
public override bool AllowAutoload { get { return true; } }
protected override string GameName { get { return "Zombie Survival"; } }
Expand Down
10 changes: 5 additions & 5 deletions MCGalaxy/Modules/Games/ZombieSurvival/ZSGame.Round.cs
Expand Up @@ -315,20 +315,20 @@ public sealed partial class ZSGame : RoundsGame
}
}

static void RewardMoney(Player p, ZSData data, Player[] alive, Random rnd) {
void RewardMoney(Player p, ZSData data, Player[] alive, Random rnd) {
if (p.IsLikelyInsideBlock()) {
p.Message("You may not hide inside a block! No " + Server.Config.Currency + " for you.");
return;
}

if (alive.Length == 0) {
AwardMoney(p, 1, 5,
rnd, data.CurrentInfected);
AwardMoney(p, Config.ZombiesRewardMin, Config.ZombiesRewardMax,
rnd, data.CurrentInfected * Config.ZombiesRewardMultiplier);
} else if (alive.Length == 1 && !p.infected) {
AwardMoney(p, 5, 10,
AwardMoney(p, Config.SoleHumanRewardMin, Config.SoleHumanRewardMax,
rnd, 0);
} else if (alive.Length > 1 && !p.infected) {
AwardMoney(p, 2, 6,
AwardMoney(p, Config.HumansRewardMin, Config.HumansRewardMax,
rnd, 0);
}
}
Expand Down

0 comments on commit 4cd7f55

Please sign in to comment.