bzr branch
http://gegoxaren.bato24.eu/bzr/vqdr/trunk
2
by Gustav Hartvigsson
* moved README.md to README |
1 |
Vala/Very Quick Dice Roller |
2 |
||
3 |
To see README about libvqdr, please see ./src/libvqdr/README |
|
4 |
||
5 |
VQDR will consist of two parts, the backend library, and the front end. |
|
6 |
||
7 |
The backend libray, libvqdr, provides the logic for parsing dice expression |
|
8 |
strings, and doing the calculations needed to perform the dice rolls. |
|
9 |
||
10 |
The frontend has yet to be written. |
|
11 |
||
19
by Gustav Hartvigsson
Added Round Up and Round Down function classes. |
12 |
For up-to-date code, go to: |
13 |
https://launchpad.net/vqdr |
|
14 |
||
2
by Gustav Hartvigsson
* moved README.md to README |
15 |
BUILDING
|
59
by Gustav Hartvigsson
Added section on development guidelines. |
16 |
|
17 |
------------- |
|
18 |
$ mkdir build |
|
19 |
$ cd build |
|
20 |
$ meson .. |
|
21 |
$ ninja |
|
22 |
------------- |
|
2
by Gustav Hartvigsson
* moved README.md to README |
23 |
|
24 |
DICE EXPRESSION SYNTAX |
|
25 |
||
59
by Gustav Hartvigsson
Added section on development guidelines. |
26 |
A dice expression is simple. |
27 |
||
28 |
---- Basics ---- |
|
29 |
[n]d[m], [n]t[m] - [n] dices with [m] sides. |
|
30 |
[e1] [op] [e2] - Use operator [op] on expressions [e1] and [e2] |
|
31 |
|
|
32 |
[func]([e...]) - Use function [func] on the expression(s) [e...] |
|
33 |
---------------- |
|
34 |
||
35 |
HACKING (DEVELOPMENT GUIDELINES) |
|
36 |
||
37 |
Please use stardard vala naming convetion. This to make it as easy to read as |
|
38 |
passible, and minimise any errors when interating with other libraries. |
|
39 |
||
40 |
INDENTATION |
|
41 |
||
42 |
Always use two spaces for indentation detween levels. |
|
43 |
|
|
44 |
INTEGER TYPES |
|
45 |
||
46 |
Use int[n] types instead of int and long. This to guarentee that the |
|
47 |
behviour is the same on all platforms. |
|
48 |
||
49 |
TYPE NAMES |
|
50 |
|
|
51 |
All type names should start with a capital letter, and each word in the name |
|
52 |
should start with a capital letter. No seperation should be made between |
|
53 |
the words in the name. |
|
54 |
||
55 |
--- vala --- |
|
56 |
class ClownFactory {...} |
|
57 |
------------ |
|
58 |
||
59 |
FUNCTIONS AND METHODS |
|
60 |
|
|
61 |
Function and method namse should has the standard naming convetion of vala: |
|
62 |
|
|
63 |
--- vala --- |
|
64 |
void foo_bar (int something); |
|
65 |
----------- |
|
66 |
||
67 |
* There should be a space befor the paranthesis. |
|
68 |
* Use underlines to seperate words in the function name. |
|
69 |
||
70 |
It is advicable to have the function names as short as possible, but also |
|
71 |
descriptive. Sometimes this leads to a copromise between readability, and |
|
72 |
brevity. |
|
73 |
||
74 |
VARIABELS |
|
75 |
||
76 |
When defining variables use underlines between words: |
|
77 |
||
78 |
--- vala --- |
|
79 |
string my_fun_string; |
|
80 |
----------- |
|
81 |
||
82 |
ENUMS |
|
83 |
|
|
84 |
When defining enums, make sure that the 0'th value is invalid, this to avoid |
|
85 |
any potential NULL traps. |
|
86 |
||
87 |
Always define a last value named _NUM_VAL, this will be used for validation |
|
88 |
of data. |
|
89 |
||
90 |
--- vala --- |
|
91 |
enum Clowns { |
|
92 |
INVALID = 0, |
|
93 |
BENNY = 1, |
|
94 |
CARL, |
|
95 |
CRUSTY, |
|
96 |
HOMER, |
|
97 |
_NUM_VAL; |
|
98 |
} |
|
99 |
------------ |
|
100 |
||
101 |
It is advicable to define a to_string method for the enums. To keep track |
|
102 |
of the to_string functions cases, it is advicable to add a static assert |
|
103 |
to the body of the function to catch problems at compile time. |
|
104 |
|
|
105 |
--- vala --- |
|
106 |
enum Clowns { |
|
107 |
..., |
|
108 |
_NUM_VAL; |
|
109 |
||
110 |
public string to_string () { |
|
63
by Gustav Hartvigsson
[README] |
111 |
static_assert (Clowns._NUM_VAL == 4 + 1); |
59
by Gustav Hartvigsson
Added section on development guidelines. |
112 |
switch (this) { |
113 |
case (BENNY): |
|
114 |
return "BENNY"; |
|
115 |
case (CARL): |
|
116 |
return "CARL"; |
|
117 |
.... |
|
118 |
default: |
|
119 |
assert_not_reached (); |
|
120 |
} |
|
121 |
} |
|
122 |
} |
|
123 |
------------ |
|
124 |
|