This repository was archived by the owner on Mar 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathItemsList.cs
More file actions
89 lines (78 loc) · 1.48 KB
/
ItemsList.cs
File metadata and controls
89 lines (78 loc) · 1.48 KB
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
/*
* Erstellt mit SharpDevelop.
* Benutzer: rschmidt
* Datum: 23.11.2008
* Zeit: 11:23
*
* Sie können diese Vorlage unter Extras > Optionen > Codeerstellung > Standardheader ändern.
*/
using System;
using System.Collections;
using WLA;
using V_Learning_Aid;
using System.Windows.Forms;
namespace WLA
{
/**
* List of items
*/
public class ItemsList
{
public ArrayList ytems = new ArrayList();
public int p = 0;
/**
* Constructor
*/
public ItemsList()
{
}
/**
* Shuffle items
*/
public void Shuffle()
{
Random r = new Random();
for (int cnt = 0; cnt < ytems.Count; cnt++)
{
object tmp = ytems[cnt];
int idx = r.Next(ytems.Count - cnt) + cnt;
ytems[cnt] = ytems[idx];
ytems[idx] = tmp;
}
}
/**
* Add item
*/
public void Add(Item item)
{
ytems.Add(item);
}
/**
* Get next item
*/
public Item Next()
{
// Traverse loop
if(!Settings.getBool("rndSeq") || Settings.getBool("uniqItems")) {
return ((Item)ytems[p++%ytems.Count]);
}
// Select random item
Random rnd = new Random();
int i = rnd.Next(0, ytems.Count);
return ((Item)ytems[i]);
}
/**
* Shuffle
*/
public bool Dice ()
{
int chance = Settings.getInt ("chanceInt");
if (chance >= 100) {
return true;
}
Random dice = new Random();
int roll = dice.Next(0, 100);
return roll > chance;
}
}
}