Making code-batchfile for building turnbased demo area

This commit is contained in:
Griatch 2023-05-07 20:50:40 +02:00
parent 4a8ed84a1a
commit 03bd61753b
3 changed files with 61 additions and 5 deletions

View file

@ -88,7 +88,6 @@ import datetime
import re
from django.conf import settings
from evennia import CmdSet, DefaultRoom, default_cmds, gametime, utils
# error return function, needed by Extended Look command
@ -361,7 +360,9 @@ class CmdExtendedRoomLook(default_cmds.CmdLook):
if detail:
# we found a detail
# tell all the objects in the room we're looking closely at something
caller.location.msg_contents(f"$You() $conj(look) closely at {args}.\n", from_obj=caller)
caller.location.msg_contents(
f"$You() $conj(look) closely at {args}.\n", from_obj=caller
)
# show the detail to the player
caller.msg(detail)
return

View file

@ -1,8 +1,8 @@
# Evadventure combat demo
# Evadventure (Twitch) combat demo - using a batchcommand file.
#
# Set up a combat area for testing combat. Requires developer or superuser perm.
# Sets up a combat area for testing twitch combat. Requires developer or superuser perm.
#
# Run from in-game as batchcmd contrib.tutorials.evadventure.batchscripts.combat_demo
# Run from in-game as batchcmd evadventure.batchscripts.combat_demo
#
# start from limbo

View file

@ -0,0 +1,55 @@
# Evadventure (Turnbased) combat demo - using a batch-code file.
#
# Sets up a combat area for testing turnbased combat.
#
# Run from in-game as `batchcode evadventure.batchscripts.combat_demo`
#
# HEADER
from evennia import DefaultExit, create_object, search_object
from evennia.contrib.tutorials.evadventure.characters import EvAdventureCharacter
from evennia.contrib.tutorials.evadventure.combat_turnbased import TurnCombatCmdSet
from evennia.contrib.tutorials.evadventure.npcs import EvAdventureNPC
from evennia.contrib.tutorials.evadventure.rooms import EvAdventureRoom
# CODE
# Make the player an EvAdventureCharacter
player = caller # caller is injected by the batchcode runner, it's the one running this script
player.swap_typeclass(EvAdventureCharacter, clean_attributes=True)
# add the Turnbased cmdset
player.cmdset.add(TurnCombatCmdSet, persistent=True)
# create a weapon and an item to use
create_object(
"contrib.tutorials.evadventure.objects.EvAdventureWeapon",
key="Sword",
location=player,
attributes=[("desc", "A sword.")],
)
create_object(
"contrib.tutorials.evadventure.objects.EvAdventureConsumable",
key="Potion",
location=player,
attributes=[("desc", "A potion.")],
)
# start from limbo
limbo = search_object("#2")[0]
arena = create_object(EvAdventureRoom, key="Arena", attributes=[("desc", "A large arena.")])
# Create the exits
arena_exit = create_object(DefaultExit, key="Arena", location=limbo, destination=arena)
back_exit = create_object(DefaultExit, key="Back", location=arena, destination=limbo)
# create the NPC dummy
create_object(
EvAdventureNPC,
key="Dummy",
location=arena,
attributes=[("desc", "A training dummy."), ("hp", 1000), ("hp_max", 1000)],
)