TypeScript is a "strict superset" of javascript. This means that in a TypeScript file (.ts), you can write pure javascript code if you want. But you can also use TypeScript syntax! Here are the most important things :
class MyClass{ private someNumber: number = 9; private someString: string = "blah"; constructor(test: number){ this.someNumber = test; this.methodTest(); } public methodTest(): void{ this.someString = "blablah"; } }So, here I create a class called MyClass with two private attributes, someNumber and someString. I also define the constructor (a special method called when we create a variable using this class as a type), and another method called methodTest. You can see that the keyword this is used to refer to the current object we're working in. This shouldn't be too hard if you already know other object-oriented programming languages. Check here if you want to understand the concept.
The compiling script takes all the code located in the code directory, all the ascii art in the ascii directory and all the text in the text directory, and gather all that in a single candybox2.js file. This candybox2.js file is used by the index.html file : this is why opening the index.html file launches the game.
There are two special directories to handle quests made for the Arena : code/arena/ for the TypeScript files (.ts) and ascii/arena for the ascii art.
Before creating your own quest, I advise you to try understanding and modifying the Peaceful Forest (one of the quests currently available in the Arena). It is rather simple, and working on it helps to understand how the game's code is organized.
The peaceful forest consists of two TypeScript files : code/arena/peacefulForest/peacefulForest_Quest.ts and code/arena/peacefulForest/peacefulForest_Tree.ts, and one ascii art (the logo displayed on the Arena page), ascii/arena/peacefulForest/logo.txt. So you just need to edit the TypeScript files, compile, and open the index.html file in your browser to test your changes!
Once you'll understand how the Peaceful Forest works, you can create your own quest by adding your own directory in the code/arena and the ascii/arena directories. Your quest should be hard and original! If you want it to be added to the game so that everyone can play it, send it to me by mail at aniwey@gmail.com. If your quest is interesting and functional, it will be added to the Arena. If it is hard and original enough, it will be added to the highlighted quests on top of the page :)
I want to test my quest, but the game starts from the beginning so I can't access the Arena.
If you want to start the game with everything unlocked, the easiest way is to modify the code/main/Saving.ts file. Just uncomment the lines from 17 to 135, and you'll start a game with everything unlocked, all the items in the inventory, and a lot of potions :)
So, I made my quest, but I can't access it from the Arena?
You must give the name of your quest in the Arena by modifying the line 51 in the code/main/TheArena.ts file.
You can chat with me and other quest makers on the game's IRC channel here or the game's forum here.