# Grid of monsters.
class Grid
# width of the current grid
- var width: Int
+ var width: Int is noinit
# maximum width of the grid
var max_width: Int
# height of the current grid
- var height: Int
+ var height: Int is noinit
# maximum height of the grid
var max_height: Int
# the data grid
private var grid = new Array[Array[Tile]]
- init(mw,mh,nm: Int)
- do
- self.max_width = mw
- self.max_height = mh
- self.nb_monsters = mh
- clear
- end
+ init do clear
# Reinitialize the grid with new empty tiles and monsters info
fun clear
private class CircularListIterator[E]
super IndexedIterator[E]
- redef var index: Int
+ redef var index: Int = 0
# The current node pointed.
# Is null if the list is empty.
- var node: nullable CLNode[E]
+ var node: nullable CLNode[E] is noinit
# The list iterated.
var list: CircularList[E]
redef fun item do return self.node.item
- init(list: CircularList[E])
+ init
do
self.node = list.node
- self.list = list
- self.index = 0
end
end
# Abuser iterator to read a file, see `file_open`
private class ReadFileForAbuserIterator
super Iterator[IFStream]
- redef var item: IFStream
+ var path: String
+ redef var item: IFStream is noinit
redef var is_ok = true
- init(path: String)
+ init
do
# start of service is to open the file, and return in
item = new IFStream.open(path)
private class SortAbuserIterator[E]
super Iterator[CompareQuery[E]]
# The index of the big loop
- var i: Int
+ var i: Int = 0
# The index of the small loop
- var j: Int
+ var j: Int = 0
# The array to sort
var array: Array[E]
# The query used to communicate with the user.
# For ecological concerns, a unique CompareQuery is instatiated.
- var query: nullable CompareQuery[E]
+ var query: nullable CompareQuery[E] = null
redef fun item do return query.as(not null)
- init(array: Array[E])
+ init
do
- self.array = array
# Initialize the algorithm, see `next` for the rest
- i = 0
- j = 0
if not is_ok then return
query = new CompareQuery[E](array[i], array[j])
end
redef var x: N
redef var y: N
-
- init(x, y: N)
- do
- self.x = x
- self.y = y
- end
end
# An abstract 3d point, strongly linked to its implementation `Point3d`
super Point[N]
redef var z: N
-
- init(x, y, z: N)
- do
- super
- self.z = z
- end
end
# An abstract 2d line segment
redef var point_left: P
redef var point_right: P
- init(a, b: P)
+ init
do
- if a.x < b.x then
- point_left = a
- point_right = b
- else
+ var a = point_left
+ var b = point_right
+ if a.x > b.x then
point_left = b
point_right = a
end
# The height of a tile
var height: Int
- init(image: Image, width: Int, height: Int)
+ init
do
- self.image = image
- self.width = width
- self.height = height
-
self.nb_cols = image.width / width
self.nb_rows = image.height / height
end
# The number of columns of tiles in the image
- var nb_cols: Int
+ var nb_cols: Int is noinit
# The number of rows of tiles in the image
- var nb_rows: Int
+ var nb_rows: Int is noinit
# Cache for images of tiles
var subimages = new Array[Image]
# Use space (' ') for holes in the tileset
var chars: String
- init(image: Image, width: Int, height: Int, chars: String)
- do
- super
- self.chars = chars
- end
-
# Additional space to insert horizontally between characters
# A negave value will display tile overlaped
var hspace: Int = 0 is writable
super Visitor
var writer: OStream
private var indent = 0
- init(writer: OStream) do self.writer = writer
redef fun visit(n)
do
for i in [0..indent[ do writer.write(" ")
var source: Iterator[E]
var skip_item: E
- init(source: Iterator[E], skip_item: E)
- do
- self.source = source
- self.skip_item = skip_item
-
- do_skip
- end
+ init do do_skip
fun do_skip
do
var lasts = new List[E]
- init(source: Iterator[E], length: Int)
+ init
do
- self.source = source
- self.length = length
var lasts = self.lasts
while source.is_ok and lasts.length < length do
lasts.push(source.item)
var predicate: Function[E, Bool]
- init(source: Iterator[E], predicate: Function[E, Bool])
- do
- self.source = source
- self.predicate = predicate
-
- do_skip
- end
+ init do do_skip
fun do_skip
do