It is currently 14 Jul 2020, 03:32
   
Text Size

MagicWars 1.2.0 With Script Engine!

Moderators: nantuko84, CCGHQ Admins

MagicWars 1.2.0 With Script Engine!

Postby nantuko84 » 08 Dec 2009, 17:29

Hi everyone!

I'd like to share with you what's happening with MagicWars and what will appear in new version that comes soon.
Along with many bugs fixes (and for sure new bugs ;))), MagicWars 1.2.0 will have the following features:
1) Different Printings Support: you can add different versions of the same card (e.g. 2 copies of Shock Tenth Edition and 2 copies from Onslaught set) to your deck and see then in play
2) Script Engine: now you can create your own cards! read about this below
3) Basic AI: once you've added your card, you can try one of three decks to play with

Today I'd like to start cycle of topics here describing what Script Engine is and how to add new cards to MagicWars.
So what does Script Engine mean for players? It means that since now you can add new cards by yourself. No need to wait for new releases just to get to know whether a card you wanted to play so much online was added or not. All you need is just study groovy a little (really easy language) and read future articles. They would explain what should be done to create some specific cards, what API is available and, for sure, will bring some examples of existing cards.

Let's start with card description format today.

Card location
All scripted cards are stored in cards/groovy folders. As there can be too many cards in future, we separated them using first three letters of card names. So "Shock" will be stored in cards/groovy/S/h/o/Shock.card while "Goblin Guide" in cards/groovy/G/o/b/Goblin Guide.card.

We have already generated some cards for you to help you to create magic cards. They are saved in cards/todo/<SET_NAME>. They are not counted as implemented, so to start with you need to copy them from there to cards/groovy folder (with keeping in mind 3 letter structure: S/h/o/Shock).

Card data

Here is the card file for "Shock":

Code: Select all
name = "Shock"
types = ["Instant"]
manacost = "R"
text = ["Shock deals 2 damage to target creature or player."]
prints = [
    ["10E", "C", 129732, 232],
    ["9ED", "C", 83261, 220],
    ["8ED", "C", 45352, 222],
    ["7ED", "C", 13074, 219],
    ["6ED", "C", 14609, 206],
    ["STH", "C", 5143, 98],
    ["BTD", "C", 26645, 45],
    ["ONS", "C", 39482, 227]
]

script = '''\
    addSpell({
        dealDamage($target, 2, $this)
    })
    setTarget("Creature|Player")   
'''
As you can see, there are the following fields that you can use:

name
card name, nothing special to add here
only is that it should be the same as file name

types

includes card type and its sub types
card types are "Instant", "Sorcery", "Creature", "Artifact", "Planeswalker", "Enchantment", "Land"
sub type are additional info about card type
it may be "Equipment", "Aura", as well as "Merfolk", "Wolf", etc.

manacost
mana symbols devided by spaces and with slash for hybrid, examples:
"0", "2", "B B", "B\R", "3 B R G", "2 G\U"

text
oracle text
it can be used by script so it's better to divide them into several parts
Code: Select all
   
    addAbility({
        $player.drawCard()
    })
    setDescription(text[2])
script engine parses oracle text to add static abilities, such as flying, haste, trample, deathtouch, etc.

prints
sets where this card was printed
you will see all of them in deck editor and can use any of them in your decks
print entry format:
["set code", "rarity", "multiverseId", "collectorId"]
set code should be official code of a set(you can find it here: http://en.wikipedia.org/wiki/Core_Sets)
rarity: "M","R","U" or "C"
multiverseId comes from gatherer for every card and should be unique even for the same card but from different sets http://gatherer.wizards.com/Pages/Default.aspx
collectorId can also be found in gatherer (it's an ordinal number in the set)

n.b. don't forget to put comma between several prints

script
the most important thing: script by itself
can be empty if card is so called "vanilla creature" - creature with static abilities only

there are also power and toughness for creatures
and not mandatory property color (by default card color is defined by its manacost)

That's it for today!

Finally I will give you an example how to fill data for vanilla creatures:
First opening gatherer Gatherer, type "Sky Ruin Drake" and press "Search"
it will open a card with such url:
http://gatherer.wizards.com/Pages/Card/ ... eid=192211

look at the number at the end, multiveseid, we will use it in prints:
["ZEN", "C", 192211, 66]
where 66 is collector number and can be found at the bottom:

Card #: 66

the final result will look like:

Code: Select all
name = "Sky Ruin Drake"
manacost = "4 U"
types = [ "Creature", "Drake" ]
power = 2
toughness = 5
text = ["Flying"]

prints = [
    ["ZEN", "C", 192211, 66]
]
As I said before, such card can be just copied from cards/todo/ZEN/S/k/y/Sky Ruin Drake.card to cards/groovy/S/k/y/Sky Ruin Drake.card
Then start MagicWars and you can try it!

See you
nantuko84
DEVELOPER
 
Posts: 266
Joined: 08 Feb 2009, 21:14
Has thanked: 2 times
Been thanked: 9 times

Re: MagicWars 1.2.0 With Script Engine!

Postby telengard » 09 Dec 2009, 01:35

Sounds cool. How is the performance of Groovy as far as AI etc?

~telengard
Author of Dreamblade:
viewtopic.php?f=51&t=1215
User avatar
telengard
DEVELOPER
 
Posts: 374
Joined: 23 May 2009, 23:04
Has thanked: 0 time
Been thanked: 25 times

Re: MagicWars 1.2.0 With Script Engine!

Postby nantuko84 » 09 Dec 2009, 07:30

performance for script:
now we have about 100 scripted cards, I didn't measure how much it takes to load only scripted cards, but all 650 cards are loaded by 1-2 sec.
but it is only if we are talking about card parameters loading that are described above (name,type,power,prints,etc.)
about card implementation scripts: this morning found out that GroovyEngine works much faster that GroovyShell we used before as it has cache for scripts loaded so decks containing several copies of the same card will be loaded faster. may be in future we will compile some cards into java classes, not sure at the moment

ai: it is early to talk about ai performance now, as it was initial state and ai is really basic. the main purposes of 1.2.0 was to make ai work in separate thread as second player. actually it is possible to make it acting as a bot, it will login and then click on any window as usual player does. moreover you can start two clients and run ai in both of them, then go for coffee or pop corn and enjoy them fighting with each other in different windows - you will see what they have at their hands, what they choose and so on
:)
nantuko84
DEVELOPER
 
Posts: 266
Joined: 08 Feb 2009, 21:14
Has thanked: 2 times
Been thanked: 9 times

Re: MagicWars 1.2.0 With Script Engine!

Postby Marek14 » 09 Dec 2009, 10:28

If someone was to implement things like D'Avenant Archer, No Mercy or O-Naginata, where would they go in the directory structure?
Marek14
Tester
 
Posts: 2677
Joined: 07 Jun 2008, 07:54
Has thanked: 0 time
Been thanked: 270 times

Re: MagicWars 1.2.0 With Script Engine!

Postby nantuko84 » 09 Dec 2009, 10:40

Marek14 wrote:If someone was to implement things like D'Avenant Archer, No Mercy or O-Naginata, where would they go in the directory structure?
Good question, Marek14!
They should be saved in Dav, Nom and Ona folders, skipping all non letter symbols.
nantuko84
DEVELOPER
 
Posts: 266
Joined: 08 Feb 2009, 21:14
Has thanked: 2 times
Been thanked: 9 times


Return to MagicWars

Who is online

Users browsing this forum: No registered users and 2 guests

cron

Who is online

In total there are 2 users online :: 0 registered, 0 hidden and 2 guests (based on users active over the past 10 minutes)
Most users ever online was 1371 on 09 Feb 2020, 16:22

Users browsing this forum: No registered users and 2 guests

Login Form