LS: Add WIP Life store item

This commit is contained in:
UnknownShadow200 2023-01-01 21:49:39 +11:00
parent de2fdb4c5c
commit adfce5bb5b
6 changed files with 105 additions and 13 deletions

View File

@ -554,9 +554,11 @@
<Compile Include="Modules\Games\LavaSurvival\CmdLavaSurvival.cs" /> <Compile Include="Modules\Games\LavaSurvival\CmdLavaSurvival.cs" />
<Compile Include="Modules\Games\LavaSurvival\LSConfig.cs" /> <Compile Include="Modules\Games\LavaSurvival\LSConfig.cs" />
<Compile Include="Modules\Games\LavaSurvival\LSGame.cs" /> <Compile Include="Modules\Games\LavaSurvival\LSGame.cs" />
<Compile Include="Modules\Games\LavaSurvival\LSGame.DB.cs" />
<Compile Include="Modules\Games\LavaSurvival\LSGame.Physics.cs" /> <Compile Include="Modules\Games\LavaSurvival\LSGame.Physics.cs" />
<Compile Include="Modules\Games\LavaSurvival\LSGame.Plugin.cs" /> <Compile Include="Modules\Games\LavaSurvival\LSGame.Plugin.cs" />
<Compile Include="Modules\Games\LavaSurvival\LSGame.Round.cs" /> <Compile Include="Modules\Games\LavaSurvival\LSGame.Round.cs" />
<Compile Include="Modules\Games\LavaSurvival\LSItems.cs" />
<Compile Include="Modules\Games\LavaSurvival\LSPlugin.cs" /> <Compile Include="Modules\Games\LavaSurvival\LSPlugin.cs" />
<Compile Include="Modules\Games\TNTWars\CmdTntWars.cs" /> <Compile Include="Modules\Games\TNTWars\CmdTntWars.cs" />
<Compile Include="Modules\Games\TNTWars\TWConfig.cs" /> <Compile Include="Modules\Games\TNTWars\TWConfig.cs" />
@ -576,7 +578,7 @@
<Compile Include="Modules\Games\ZombieSurvival\Commands\CmdLastLevels.cs" /> <Compile Include="Modules\Games\ZombieSurvival\Commands\CmdLastLevels.cs" />
<Compile Include="Modules\Games\ZombieSurvival\Commands\CmdQueue.cs" /> <Compile Include="Modules\Games\ZombieSurvival\Commands\CmdQueue.cs" />
<Compile Include="Modules\Games\ZombieSurvival\Commands\CmdShowQueue.cs" /> <Compile Include="Modules\Games\ZombieSurvival\Commands\CmdShowQueue.cs" />
<Compile Include="Modules\Games\ZombieSurvival\ZombieItems.cs" /> <Compile Include="Modules\Games\ZombieSurvival\ZSItems.cs" />
<Compile Include="Modules\Games\ZombieSurvival\ZSConfig.cs" /> <Compile Include="Modules\Games\ZombieSurvival\ZSConfig.cs" />
<Compile Include="Modules\Games\ZombieSurvival\ZSGame.cs" /> <Compile Include="Modules\Games\ZombieSurvival\ZSGame.cs" />
<Compile Include="Modules\Games\ZombieSurvival\ZSGame.DB.cs" /> <Compile Include="Modules\Games\ZombieSurvival\ZSGame.DB.cs" />

View File

@ -0,0 +1,38 @@
/*
Copyright 2015 MCGalaxy
Dual-licensed under the Educational Community License, Version 2.0 and
the GNU General Public License, Version 3 (the "Licenses"); you may
not use this file except in compliance with the Licenses. You may
obtain a copy of the Licenses at
http://www.opensource.org/licenses/ecl2.php
http://www.gnu.org/licenses/gpl-3.0.html
Unless required by applicable law or agreed to in writing,
software distributed under the Licenses are distributed on an "AS IS"
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
or implied. See the Licenses for the specific language governing
permissions and limitations under the Licenses.
*/
using System;
using MCGalaxy.DB;
using MCGalaxy.Eco;
using MCGalaxy.Games;
using MCGalaxy.SQL;
namespace MCGalaxy.Modules.Games.LS
{
public sealed partial class LSGame : RoundsGame
{
static void HookItems() {
Economy.RegisterItem(itemLife);
}
static void UnhookItems() {
Economy.Items.Remove(itemLife);
}
static Item itemLife = new LifeItem();
}
}

View File

@ -142,6 +142,7 @@ namespace MCGalaxy.Modules.Games.LS
Chat.MessageFromLevel(p, "λNICK &4ran out of lives, and is out of the round!"); Chat.MessageFromLevel(p, "λNICK &4ran out of lives, and is out of the round!");
p.Message("&4You can still watch, but you cannot build."); p.Message("&4You can still watch, but you cannot build.");
// TODO: Buy life message
} }
} }
} }

View File

@ -22,7 +22,7 @@ using BlockID = System.UInt16;
namespace MCGalaxy.Modules.Games.LS namespace MCGalaxy.Modules.Games.LS
{ {
internal sealed class LSData public sealed class LSData
{ {
public int TimesDied, SpongesLeft; public int TimesDied, SpongesLeft;
} }
@ -38,11 +38,12 @@ namespace MCGalaxy.Modules.Games.LS
BlockID floodBlock; BlockID floodBlock;
int curLayer, spreadDelay; int curLayer, spreadDelay;
int roundTotalSecs, floodDelaySecs, layerIntervalSecs; int roundTotalSecs, floodDelaySecs, layerIntervalSecs;
static bool hooked;
public static LSGame Instance = new LSGame(); public static LSGame Instance = new LSGame();
public LSGame() { Picker = new LevelPicker(); } public LSGame() { Picker = new LevelPicker(); }
static LSData Get(Player p) { public static LSData Get(Player p) {
object data; object data;
if (!p.Extras.TryGet("MCG_LS_DATA", out data)) { if (!p.Extras.TryGet("MCG_LS_DATA", out data)) {
data = new LSData(); data = new LSData();
@ -85,12 +86,19 @@ namespace MCGalaxy.Modules.Games.LS
protected override void StartGame() { protected override void StartGame() {
ResetPlayerDeaths(); ResetPlayerDeaths();
if (hooked) return;
hooked = true;
HookItems();
} }
protected override void EndGame() { protected override void EndGame() {
flooded = false; flooded = false;
ResetPlayerDeaths(); ResetPlayerDeaths();
if (Map != null) UpdateBlockHandlers(); if (Map != null) UpdateBlockHandlers();
hooked = false;
UnhookItems();
} }
public bool IsPlayerDead(Player p) { public bool IsPlayerDead(Player p) {

View File

@ -0,0 +1,45 @@
/*
Copyright 2015 MCGalaxy
Dual-licensed under the Educational Community License, Version 2.0 and
the GNU General Public License, Version 3 (the "Licenses"); you may
not use this file except in compliance with the Licenses. You may
obtain a copy of the Licenses at
http://www.opensource.org/licenses/ecl2.php
http://www.gnu.org/licenses/gpl-3.0.html
Unless required by applicable law or agreed to in writing,
software distributed under the Licenses are distributed on an "AS IS"
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
or implied. See the Licenses for the specific language governing
permissions and limitations under the Licenses.
*/
using System;
using MCGalaxy.Eco;
namespace MCGalaxy.Modules.Games.LS
{
sealed class LifeItem : SimpleItem
{
public LifeItem() {
Aliases = new string[] { "life", "lifes", "live", "lives" };
Price = 20;
}
public override string Name { get { return "Life"; } }
protected internal override void OnPurchase(Player p, string args) {
if (!LSGame.Instance.RoundInProgress) {
p.Message("You can only buy a life " +
"when a round of lava survival is in progress."); return;
}
if (!CheckPrice(p)) return;
LSGame.Get(p).TimesDied--;
// TODO: announce lifes left
Economy.MakePurchase(p, Price, "%3Life:");
}
}
}

View File

@ -18,9 +18,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using MCGalaxy.Commands; using MCGalaxy.Commands;
using MCGalaxy.DB;
using MCGalaxy.Eco; using MCGalaxy.Eco;
using MCGalaxy.Games;
namespace MCGalaxy.Modules.Games.ZS namespace MCGalaxy.Modules.Games.ZS
{ {
@ -126,7 +124,7 @@ namespace MCGalaxy.Modules.Games.ZS
protected internal override void OnPurchase(Player p, string args) { protected internal override void OnPurchase(Player p, string args) {
if (!CheckPrice(p, Price, "an invisibility potion")) return; if (!CheckPrice(p, Price, "an invisibility potion")) return;
if (!ZSGame.Instance.Running || !ZSGame.Instance.RoundInProgress) { if (!ZSGame.Instance.RoundInProgress) {
p.Message("You can only buy an invisiblity potion " + p.Message("You can only buy an invisiblity potion " +
"when a round of zombie survival is in progress."); return; "when a round of zombie survival is in progress."); return;
} }
@ -177,7 +175,7 @@ namespace MCGalaxy.Modules.Games.ZS
protected internal override void OnPurchase(Player p, string args) { protected internal override void OnPurchase(Player p, string args) {
if (!CheckPrice(p, Price, "a revive potion")) return; if (!CheckPrice(p, Price, "a revive potion")) return;
if (!ZSGame.Instance.Running || !ZSGame.Instance.RoundInProgress) { if (!ZSGame.Instance.RoundInProgress) {
p.Message("You can only buy a revive potion " + p.Message("You can only buy a revive potion " +
"when a round of zombie survival is in progress."); return; "when a round of zombie survival is in progress."); return;
} }