Skip to content
Open
8 changes: 7 additions & 1 deletion config.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@
"plant": 12,
"water": 6,
"attack": 12,
"thug": 12
"thug": 12,
"blood": 6,
"eclipse": 5
},

"FEATURES": {
"audrey": false
}
}
2 changes: 1 addition & 1 deletion core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions docker_init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

. ./venv/bin/activate
python launcher.py
4 changes: 3 additions & 1 deletion dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ RUN python -m venv venv \
&& . ./venv/bin/activate \
&& pip install -U -r requirements.txt

EXPOSE 8000
EXPOSE 8000

CMD ["./docker_init.sh"]
49 changes: 49 additions & 0 deletions time2grow/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down