-
Notifications
You must be signed in to change notification settings - Fork 128
/
create_quest.html
93 lines (86 loc) · 5.42 KB
/
create_quest.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<!DOCTYPE HTML>
<html>
<head>
<title>Candy Box 2 - how to create a quest?</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<style type="text/css">
body{
font-family: monospace;
font-size: 15px;
}
p{
text-indent: 2em;
}
.code{
background-color: rgb(210, 210, 210);
}
</style>
</head>
<body>
<i>Before starting to create a quest for Candy Box 2, make sure you got the code to work by following instructions on <a href="source_code.html">this page</a></i>.
<br/>
<br/>
<h3>What does TypeScript code look like?</h3>
<p>
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 :
<ul>
<li>The compiling script will give you error messages if something is wrong with your code. And that's incredibly useful.</li>
<br/>
<li>When you create a variable, you can give it a type, like that : <span class="code">var stuff: number = 5;</span>. Allowed types are number, boolean, string, or any class you've created. Later, if you're using your variable the wrong way, the compiler will give you an error message, which is very useful.</li>
<br/>
<li>You can create classes! Here's a small example :<br/>
<pre class="code">
class MyClass{
private someNumber: number = 9;
private someString: string = "blah";
constructor(test: number){
this.someNumber = test;
this.methodTest();
}
public methodTest(): void{
this.someString = "blablah";
}
}
</pre>
So, here I create a class called <span class="code">MyClass</span> with two private attributes, <span class="code">someNumber</span> and <span class="code">someString</span>. I also define the constructor (a special method called when we create a variable using this class as a type), and another method called <span class="code">methodTest</span>. You can see that the keyword <span class="code">this</span> 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 <a href="https://en.wikipedia.org/wiki/Object-oriented_programming">here</a> if you want to understand the concept.
</li>
</ul>
</p>
<br/>
<h3>What does the compiling script (compile.sh or compile.bat) do?</h3>
<p>
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.
</p>
<br/>
<h3>So, how do I create a quest?</h3>
<p>
There are two special directories to handle quests made for the Arena : <span class="code">code/arena/</span> for the TypeScript files (.ts) and <span class="code">ascii/arena</span> for the ascii art.
</p>
<p>
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.
</p>
<p>
The peaceful forest consists of two TypeScript files : <span class="code">code/arena/peacefulForest/peacefulForest_Quest.ts</span> and <span class="code">code/arena/peacefulForest/peacefulForest_Tree.ts</span>, and one ascii art (the logo displayed on the Arena page), <span class="code">ascii/arena/peacefulForest/logo.txt</span>. So you just need to edit the TypeScript files, compile, and open the index.html file in your browser to test your changes!
</p>
<p>
Once you'll understand how the Peaceful Forest works, you can create your own quest by adding your own directory in the <span class="code">code/arena</span> and the <span class="code">ascii/arena</span> 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 [email protected]. 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 :)
</p>
<br/>
<h3>Additional informations</h3>
<p>
<b>I want to test my quest, but the game starts from the beginning so I can't access the Arena.</b>
<br/><br/>
If you want to start the game with everything unlocked, the easiest way is to modify the <span class="code">code/main/Saving.ts</span> 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 :)
</p>
<p>
<b>So, I made my quest, but I can't access it from the Arena?</b>
<br/><br/>
You must give the name of your quest in the Arena by modifying the line 51 in the <span class="code">code/main/TheArena.ts</span> file.
</p>
<br/>
<h3>I've got a question or a problem</h3>
<p>
You can chat with me and other quest makers on the game's IRC channel <a href="http://webchat.quakenet.org/?channels=candybox2&uio=d4">here</a> or the game's forum <a href="http://forum.candybox2.net">here</a>.
</p>
</body>
</html>