-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPuzzleRequirement.cpp
More file actions
41 lines (33 loc) · 1.25 KB
/
PuzzleRequirement.cpp
File metadata and controls
41 lines (33 loc) · 1.25 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
//
// PuzzleRequirement.cpp
// AdvProgEX1
//
// Created by Alexander Shugaley on 09/12/2017.
// Copyright © 2017 Alexander Shugaley. All rights reserved.
//
#include "PuzzleRequirement.h"
PuzzleRequirement::PuzzleRequirement(int l, int t, int r, int b) : l(l), t(t), r(r), b(b){
this->falseTypes = vector<PuzzleType>();
}
void PuzzleRequirement::addFalseType(PuzzleType&& type){
falseTypes.push_back(type);
}
vector<PuzzleType>& PuzzleRequirement::getFalseTypesVector(){
return this->falseTypes;
}
bool PuzzleRequirement::typeSatisfiesReq(const PuzzleType& type) const{
// if the type is one of the false type (types that were already checked and found not valid)
// then it of course it doesn't satisfies the requirement
for(auto pieceType : falseTypes){
if(pieceType == type)
return false;
}
// if it is not known yet as a type that doesn't satisfies te requirement -
// check if it is in the right format.
bool leftOK = l == JOKER || l == type.getLeft();
bool topOK = t == JOKER || t == type.getTop();
bool rightOK = r == JOKER || r == type.getRight();
bool botOK = b == JOKER || b == type.getBot();
bool satisfiesReq = leftOK && topOK && rightOK && botOK;
return satisfiesReq;
}