diff options
Diffstat (limited to 'src/plugins/pluginConditionRandom.cpp')
-rw-r--r-- | src/plugins/pluginConditionRandom.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/plugins/pluginConditionRandom.cpp b/src/plugins/pluginConditionRandom.cpp new file mode 100644 index 0000000..42a4e00 --- /dev/null +++ b/src/plugins/pluginConditionRandom.cpp | |||
@@ -0,0 +1,31 @@ | |||
1 | #include "condition.h" | ||
2 | #include <stdlib.h> | ||
3 | |||
4 | class ConditionRandom : public Condition | ||
5 | { | ||
6 | public: | ||
7 | ConditionRandom() | ||
8 | { | ||
9 | } | ||
10 | |||
11 | virtual ~ConditionRandom() | ||
12 | { | ||
13 | } | ||
14 | |||
15 | virtual bool shouldExec( class Runner &, class Target & ) | ||
16 | { | ||
17 | if( (random()/(double)RAND_MAX) >= .5 ) | ||
18 | return true; | ||
19 | return false; | ||
20 | } | ||
21 | |||
22 | virtual Condition *clone() | ||
23 | { | ||
24 | return new ConditionRandom(); | ||
25 | } | ||
26 | }; | ||
27 | |||
28 | #include <bu/plugger.h> | ||
29 | PluginInterface3( pluginConditionRandom, random, ConditionRandom, Condition, | ||
30 | "Mike Buland", 0, 1 ); | ||
31 | |||