summaryrefslogtreecommitdiff
path: root/lib/Enigmatic/RotorBox.pm
blob: caf7ed19508266438bb62b0b426ed496e4a0e945 (plain)
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
package Enigmatic::RotorBox; 
use DAKKAR::p 'class';
use Enigmatic::Rotor;
use Enigmatic::Types 'RotorT';
use MooseX::Types::Structured qw(Map);
use MooseX::Types::Moose qw(Str);
use Moose::Util::TypeConstraints;
 
has rotorset => (
    is => 'ro',
    isa => Map[Str,RotorT],
    lazy_build => 1,
    traits => ['Hash'],
    handles => {
        get => 'get',
    },
);
 
sub _build_rotorset {
    my %rotors = (
        => { wiring => 'EKMFLGDQVZNTOWYHXUSPAIBRCJ'notches => ['Q'] },
        II => { wiring => 'AJDKSIRUXBLHWTMCQGZNPYFVOE'notches => ['E'] },
        III => { wiring => 'BDFHJLCPRTXVZNYEIWGAKMUSQO'notches => ['V'] },
        IV => { wiring => 'ESOVPZJAYQUIRHXLNFTGKDCMWB'notches => ['J'] },
        => { wiring => 'VZBRGITYUPSDNHLXAWMJQOFECK'notches => ['Z'] },
        VI => { wiring => 'JPGVOUMFYQBENHZRDKASXLICTW'notches => ['M','Z'] },
        VII => { wiring => 'NZJHGRCXMYSWBOUFAIVLPEKQDT'notches => ['M','Z'] },
        VIII => { wiring => 'FKQHTLXOCBJSPDZRAMEWNIUYGV'notches => ['M','Z'] },
        Beta => { wiring => 'LEYJVCNIXWPBQMDRTAKZGFUHOS'notches => [] },
        Gamma => { wiring => 'FSOKANUERHMBTIYCWLQPZXVGJD'notches => [] },
    );
 
    $_ = Enigmatic::Rotor->new($_for values %rotors;
    return \%rotors;
}