diff --git a/config.example.json b/config.example.json index db787ae..6828237 100644 --- a/config.example.json +++ b/config.example.json @@ -60,6 +60,12 @@ "plant": 12, "water": 6, "attack": 12, - "thug": 12 + "thug": 12, + "blood": 6, + "eclipse": 5 + }, + + "FEATURES": { + "audrey": false } } diff --git a/core/__init__.py b/core/__init__.py index 7bc1886..1665c23 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -20,5 +20,5 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ -from .config import config +from .config import config, feature_enabled from .logger import ColourFormatter diff --git a/core/config.py b/core/config.py index b6e0846..c473f0e 100644 --- a/core/config.py +++ b/core/config.py @@ -4,3 +4,7 @@ with open("config.json", "r") as fp: config: dict[Any, Any] = json.load(fp) + + +def feature_enabled(feature_name: str) -> bool: + return config["FEATURES"][feature_name] if feature_name in config["FEATURES"] else False \ No newline at end of file diff --git a/docker_init.sh b/docker_init.sh new file mode 100644 index 0000000..fb55cc7 --- /dev/null +++ b/docker_init.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +. ./venv/bin/activate +python launcher.py \ No newline at end of file diff --git a/dockerfile b/dockerfile index 04c5eed..1972368 100644 --- a/dockerfile +++ b/dockerfile @@ -8,4 +8,6 @@ RUN python -m venv venv \ && . ./venv/bin/activate \ && pip install -U -r requirements.txt -EXPOSE 8000 \ No newline at end of file +EXPOSE 8000 + +CMD ["./docker_init.sh"] \ No newline at end of file diff --git a/time2grow/bot.py b/time2grow/bot.py index 4c0f8e7..330319d 100644 --- a/time2grow/bot.py +++ b/time2grow/bot.py @@ -38,6 +38,7 @@ logger: logging.Logger = logging.getLogger(__name__) +AUDREY_FEATURE = 'audrey' class Bot(commands.Bot): def __init__(self, *, server: Server, database: Database) -> None: @@ -114,6 +115,54 @@ async def plant(self, ctx: commands.Context) -> None: self.dispatch({"extra": {"event": "create", "username": username}}) await self.database.update_stats(username, planted=1) + @commands.command() + @commands.cooldown(1, core.config["COOLDOWNS"]["eclipse"] * 60, commands.Bucket.user) + async def eclipse(self, ctx: commands.Context) -> None: + if not core.feature_enabled(AUDREY_FEATURE): + return + + username: str = ctx.author.name + + if username not in self.plants: + await ctx.send("A cosmic ray hits the ground, and nothing happened, cause you don't have a plant") + return + + plant: Plant = self.plants[username] + if plant.dead: + await ctx.send("Your plant is dead RIP. Buy a new one.") + return + + await ctx.send(f"{username}, your plant has been hit by a cosmic ray and mutated!! MyAvatar") + plant.plant_type = PlantType.AUDREY + self.dispatch({"extra": {"event": "eclipse", "username": username}}) + + @commands.command() + @commands.cooldown(1, core.config["COOLDOWNS"]["blood"] * 60, commands.Bucket.user) + async def blood(self, ctx: commands.Context) -> None: + if not core.feature_enabled(AUDREY_FEATURE): + return + + username: str = ctx.author.name + + if username not in self.plants: + await ctx.send("You have spilled blood for nothing... Buy a plant FamilyMan") + return + + plant: Plant = self.plants[username] + if plant.dead: + await ctx.send("Your plant is dead RIP. Buy a new one.") + return + + if plant.plant_type == PlantType.BASIC: + await ctx.send("Your plant would not like the taste of blood. Maybe an unexpected '?eclipse' would change their thirst...") + return + + await ctx.send(f"{username} makes a sacrifice to feed his carnivorous plant MyAvatar") + await plant.update(blood=True) + + self.dispatch({"extra": {"event": "water", "username": username}}) + await self.database.update_stats(username, watered=1) + @commands.command() @commands.cooldown(1, core.config["COOLDOWNS"]["eclipse"] * 60, commands.Bucket.user) async def eclipse(self, ctx: commands.Context) -> None: