Bits and bobs to help more packs pass validation.
[rock.divinelegy.git] / Domain / VOs / StepMania / Difficulty.php
1 <?php
2
3 namespace Domain\VOs\StepMania;
4
5 use Domain\Exception\InvalidDifficultyException;
6
7 class Difficulty implements IDifficulty
8 {
9 protected $stepManiaName;
10 protected $itgName;
11
12 //XXX: Common names used in simfiles. We'll map them to standard names.
13 //Taken from https://github.com/openitg/openitg/blob/master/src/Difficulty.cpp
14 private $_namesToSmNames = array(
15 "Beginner" => 'Beginner',
16 "Easy" => 'Easy',
17 "Basic" => 'Easy',
18 "Light" => 'Easy',
19 "Medium" => 'Medium',
20 "Another" => 'Medium',
21 "Trick" => 'Medium',
22 "Standard" => 'Medium',
23 "Difficult" => 'Medium',
24 "Hard" => 'Hard',
25 "Ssr" => 'Hard',
26 "Maniac" => 'Hard',
27 "Heavy" => 'Hard',
28 "Smaniac" => 'Challenge',
29 "Challenge" => 'Challenge',
30 "Expert" => 'Challenge',
31 "Oni" => 'Challenge',
32 "Edit" => 'Edit'
33 );
34
35 private $_smNamesToItgNames = array(
36 'Beginner' => 'Novice',
37 'Easy' => 'Easy',
38 'Medium' => 'Medium',
39 'Hard' => 'Hard',
40 'Challenge' => 'Expert',
41 'Edit' => 'Edit'
42 );
43
44 public function __construct($name) {
45 $ucName = ucfirst($name);
46 if(array_key_exists($ucName, $this->_namesToSmNames)) {
47 $this->stepManiaName = $this->_namesToSmNames[$ucName];
48 $this->itgName = $this->_smNamesToItgNames[$this->stepManiaName];
49 } else {
50 throw new InvalidDifficultyException(sprintf('Invalid difficulty: %s', $name));
51 }
52 }
53
54 public function getITGName() {
55 return $this->itgName;
56 }
57
58 public function getStepManiaName() {
59 return $this->stepManiaName;
60 }
61 }