Commit 19f2e4da authored by kimon-satan's avatar kimon-satan

initial commit

parents
Caterpillar
===========
This is the home of Caterpillar or Cat for short.
Clone the repository and RUNME to get started.
If you've come here straight from the Mock Turtle then head over to http://igor.gold.ac.uk/~skata001/underland/pt3/classc.html and watch the videos first
Enjoy, but not too much !
#!/bin/bash
os=$(uname -s)
os=${os:0:4}
if [ $os == "MSYS" ]; then
var="#define WIN64"
sed -i '3s/.*/#define WIN64/' shrooms/A.cpp
sed -i '3s/.*/#define WIN64/' shrooms/G.h
sed -i '3s/.*/#define WIN64/' shrooms/V.h
fi
function pause {
local count=0
while [ $count -lt $1 ]; do
echo ...
sleep 2
let count=count+1
done
}
clear
pause 2
echo "Hey dude"
pause 1
echo "I'm Caterpillar but you can call me the Cat"
pause 1
echo "Underland getting you down eh ?"
pause 1
echo "It does that to every cat in the end."
pause 1
echo "Nevermind I have a little pickmeup… if you know what I mean."
pause 2
clear
pause 1
echo "Take a look inside the folder shrooms"
pause 1
echo "Inside there is purest collection of C++ in the whole of Underland"
pause 1
echo "You got A's you got B's you got C's ... "
pause 1
echo "Well you catch my drift"
pause 2
clear
pause 1
echo "But listen you can't do that stuff raw you know"
pause 1
echo "Gotta compile it b4 you run it dude"
pause 2
echo "Why don't you compile up some A.cpp"
pause 2
echo "You won't be disappointed"
if [ $os == "MSYS" ]; then
pause 2
echo "Hey are you using Windows and MSYS ?"
pause 2
echo "If so you'll need to add the compiler flag '-std=c++11' to your g++ commands"
fi
#include "cauldron.h"
#include "utils.h"
using namespace std;
using namespace Utils;
void StartBoil(){
printVerticalDots(5,200);
cout << "bubble \n";
pause(1);
cout << "gurgle \n";
pause(1);
cout << "bubble \n";
pause(2);
cout << "Great the water is boiling \n";
pause(1);
cout << "We're almosssssst ready \n";
pause(1);
cout << "All I need now is my cookbook \n";
pause(1);
cout << "This is a dynamic library \n";
pause(2);
cout << "First you have to make it \n";
pause(1);
cout << "Find the right recipe in the makefile and make it \n";
pause(1);
cout << "Have a look in the folder libs and you should see libcookbook.dylib (cookbook.dll for windows) right there \n";
pause(2);
cout << "Once you have done that you need to add the correct library search paths to the makefile \n";
pause(1);
cout << "Do this by adding the path with a -L to the variable LIBRARY_PATHS \n"; pause(1);
cout << "Then you need to to add the library to the shrooms recipe using a -l flag \n";
pause(1);
cout << "After all this we finally will be ready to make ssssome sssssshrooms. Make shrooms and then run the output \n";
pause(2);
}
#pragma once
void StartBoil();
This diff is collapsed.
#include "D.h"
#include "F.h"
#include "G.h"
int main( int argc, const char* argv[] )
{
string scoreFilePath = "";
bool isValidFile = true;
if(argc < 2)
{
isValidFile = false;
}
else
{
scoreFilePath = string(argv[1]);
isValidFile = Utils::checkFilePath(scoreFilePath);
}
if(!isValidFile)
{
cout << "Dude \n";
Utils::printVerticalDots(2, 1000);
cout << "To catch this trip, you need to pass a valid path to your score file as an argument.\n";
Utils::printVerticalDots(2, 1000);
cout << "For example ~/Desktop/aiw_skata001" << endl;
Utils::printVerticalDots(2, 1000);
cout << "Relax dude. Have another go." << endl;
return 0;
}
Utils::readLevelsFile();
Utils::readScoreFile(scoreFilePath);
int score = Utils::calcScores();
if(score < 4)
{
cout << "Dude \n";
Utils::printVerticalDots(2, 1000);
cout << "It looks like something's going down in your score file.\n";
Utils::printVerticalDots(2, 1000);
cout << "Try cooking up that A again and come back here later.\n";
return 0;
}
Utils::submitAnswer("301", "profound");
Utils::writeScoreFile(scoreFilePath);
for(int i = 5; i >0; i--){
for(int j =0; j < i; j ++) printf(".");
printf("\n");
std::this_thread::sleep_for (std::chrono::seconds(1));
}
OtherStarPattern();
StarPattern();
for(int i = 30; i >0; i--){
printf(".");
printf("\n");
Utils::millisleep(100);
}
printf( "Whoah ! \n");
Utils::pause(1);
printf( "Duuuuuuude ! \n");
Utils::pause(1);
printf( "That was profound ! \n");
Utils::pause(1);
printf( "If you want more then you're gonna have to work for it \n" );
Utils::pause(2);
printf( "First compile up some V.cpp and W.cpp but make each of them separately as a .o file\n");
Utils::pause(1);
printf( "You're gonna need the -c flag for that\n");
Utils::pause(1);
printf( "When you've done all that link the resulting .o files together with U.cpp \n");
Utils::pause(1);
printf( "Then run it and have the time of your life !\n");
}
#include "D.h"
#include "F.h"
void StarPattern(){
for(int j = 0; j < 100; j++){
AddHorizontalSpace(j);
for(int i = 0; i < 5; i++){
printf( " * " );
}
printf( "\n");
AddHorizontalSpace(j);
for(int i = 0; i < 5; i++){
printf( " * * " );
}
printf( "\n");
AddHorizontalSpace(j);
for(int i = 0; i < 5; i++){
printf( " *** *** " );
}
printf( "\n");
AddHorizontalSpace(j);
for(int i = 0; i < 5; i++){
printf( " * * * " );
}
printf( "\n");
AddHorizontalSpace(j);
for(int i = 0; i < 5; i++){
printf( " * * " );
}
printf( "\n");
std::this_thread::sleep_for (std::chrono::milliseconds(50));
}
}
#pragma once
#include <stdio.h>
#include <thread> // std::this_thread::sleep_for
#include <chrono> // std::chrono::seconds
#include "G.h"
void StarPattern();
#include "F.h"
void OtherStarPattern(){
for(int j = 0; j < 100; j++){
AddHorizontalSpace(j%5);
for(int i =0; i < 5; i++){
printf("*");
AddHorizontalSpace(j%10);
}
printf( "\n");
Utils::millisleep(50);
}
}
void AddHorizontalSpace(int i)
{
for(int j =0; j < i ; j++)printf(" ");
}
#pragma once
#include <stdio.h>
#include <thread> // std::this_thread::sleep_for
#include <chrono> // std::chrono::seconds
#include "G.h"
void OtherStarPattern();
void AddHorizontalSpace(int i);
This diff is collapsed.
#ifndef __UTILS__
#define __UTILS__
#include "stdio.h"
#include "string.h"
#include <chrono>
#include <stdlib.h>
#ifdef WIN32
#include "windows.h"
#endif
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
using namespace std;
namespace Utils{
struct Line {
string level;
string crc;
string word;
};
struct Level
{
string level;
int points;
string word;
};
extern string username;
extern int errors;
extern map<string, Level> levelMap;
extern map<string, Line> lineMap;
void submitAnswer(string level, string word);
int calcScores();
bool checkUsername();
bool checkLevelCode(int level, string crc);
bool checkFilePath(string fp);
void readLevelsFile();
void readScoreFile(string fp);
void writeScoreFile(string fp);
void setUsername(string s);
string encryptWord(string word, string crc);
string decryptWord(string word, string crc);
string encryptLevel(string level, string crc);
string decryptLevel(string crc);
string calcrc(string st);
string calcrc(const char * ptr);
string addCRCs(string a, string b);
string subCRCs(string a, string b);
void millisleep(int ms);
void pause(int n);
void printVerticalDots(int num, int ms);
string intToString(int a);
int stringToInt(string s);
void split(const string& s, char c, vector<string>& v);
}
#endif
#include "stdio.h"
#include <thread>
#include <chrono>
#include "V.h"
#include "W.h"
int main( int argc, const char* argv[] )
{
string scoreFilePath = "";
bool isValidFile = true;
if(argc < 2)
{
isValidFile = false;
}
else
{
scoreFilePath = string(argv[1]);
isValidFile = Utils::checkFilePath(scoreFilePath);
}
if(!isValidFile)
{
cout << "Dude \n";
Utils::printVerticalDots(2, 1000);
cout << "To catch this trip, you need to pass a valid path to your score file as an argument.\n";
Utils::printVerticalDots(2, 1000);
cout << "For example ~/Desktop/aiw_skata001" << endl;
Utils::printVerticalDots(2, 1000);
cout << "Relax dude. Have another go." << endl;
return 0;
}
Utils::readLevelsFile();
Utils::readScoreFile(scoreFilePath);
int score = Utils::calcScores();
if(score < 5)
{
cout << "Dude \n";
Utils::printVerticalDots(2, 1000);
cout << "It looks like something's going down in your score file.\n";
Utils::printVerticalDots(2, 1000);
cout << "Try cooking up some of those other shrooms again and come back here later.\n";
return 0;
}
Utils::submitAnswer("302", "baking");
Utils::writeScoreFile(scoreFilePath);
Utils::printVerticalDots(20,100);
Utils::pause(1);
printf( "Hey dude \n");
Utils::pause(1);
printf( "It looks like we didn't quite get the right recipe ... \n");
Utils::pause(1);
printf( "We're gonna need to do a little more baking. \n");
Utils::pause(1);
printf( "Trust me it will be worth it. \n");
Utils::pause(2);
printf( "First I need you to make a static library out of V.o and W.o \n");
Utils::pause(1);
printf( "To do this use the command 'ar rvs VW.a V.o W.o' \n");
Utils::pause(2);
printf("Then you need to compile up some X.cpp linking VW.a \n");
Utils::pause(1);
printf("See if you can work out how to do this yourself\n");
Utils::pause(1);
printf("When you've done all that give it a run and see the sparks fly \n");
Utils::printVerticalDots(5, 100);
}
This diff is collapsed.
#ifndef __UTILS__
#define __UTILS__
#include "stdio.h"
#include "string.h"
#include <chrono>
#include <stdlib.h>
#ifdef WIN32
#include "windows.h"
#endif
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
using namespace std;
namespace Utils{
struct Line {
string level;
string crc;
string word;
};
struct Level
{
string level;
int points;
string word;
};
extern string username;
extern int errors;
extern map<string, Level> levelMap;
extern map<string, Line> lineMap;
void submitAnswer(string level, string word);
int calcScores();
bool checkUsername();
bool checkLevelCode(int level, string crc);
bool checkFilePath(string fp);
void readLevelsFile();
void readScoreFile(string fp);
void writeScoreFile(string fp);
void setUsername(string s);
string encryptWord(string word, string crc);
string decryptWord(string word, string crc);
string encryptLevel(string level, string crc);
string decryptLevel(string crc);
string calcrc(string st);
string calcrc(const char * ptr);
string addCRCs(string a, string b);
string subCRCs(string a, string b);
void millisleep(int ms);
void pause(int n);
void printVerticalDots(int num, int ms);
string intToString(int a);
void split(const string& s, char c, vector<string>& v);
}
#endif
#include "W.h"
#include <cmath>
#include "stdio.h"
#include <thread>
#include <chrono>
#define PI 3.14159
void PrintVerticalSine(int numLines)
{
for(int i = 0; i < numLines; i++)
{
float p = (float)(i+1)/numLines;
float f = sin(p * PI * 2);
int numSpaces = 15 + f * 15;
for(int j = 0; j < numSpaces; j++)printf(" ");
printf("x x x x x\n");
Utils::millisleep(50);
}
}
void PrintFunnel(int numLines, int offset)
{
int numSpaces = 7;
for(int i = 0; i < numLines; i++)
{
int spaces = numSpaces - numSpaces * (float)(i+1)/numLines;
for(int j =0; j < offset; j++)printf(" ");
for(int j = 0; j < 5; j++)
{
printf("x");
for(int k = 0; k < spaces; k++)
{
printf(" ");
}
}
printf("\n");
Utils::millisleep(50);
}
}
#pragma once
#include "V.h"
void PrintVerticalSine(int numLines);
void PrintFunnel(int numLines, int offset);
#include "W.h"
#include "V.h"
using namespace std;
using namespace Utils;
string password;
int levelIdx;
void PrintEndMessage()
{
pause(2);
printf( "Dude are you ok? You're looking a little hazy \n");
pause(1);
printf( "So you want more eh ! \n");
pause(1);
printf( "Dude I think you're a bit addicted \n");
pause(1);
printf( "Listen I'm all out of shrooms man \n");
pause(2);
printf( "Ok ok I know where you can get some more \n");
pause(1);
printf( "Go and checkout The Serpent at http://gitlab.doc.gold.ac.uk/underland/theserpent.git \n");
pause(1);
printf( "You'll need to tell him the password \n");
pause(1);
printf( "It's %s \n" , password.c_str());
pause(1);
printf( "Don't forget it ! \n");
pause(1);
printf( "Be careful man, he's a slippery character \n");
printVerticalDots(5, 300);
}
int main( int argc, const char* argv[] )
{
string scoreFilePath = "";
bool isValidFile = true;
if(argc < 2)
{
isValidFile = false;
}
else
{
scoreFilePath = string(argv[1]);
isValidFile = Utils::checkFilePath(scoreFilePath);
}
if(!isValidFile)
{
cout << "Dude \n";
Utils::printVerticalDots(2, 1000);
cout << "To catch this trip, you need to pass a valid path to your score file as an argument.\n";
Utils::printVerticalDots(2, 1000);
cout << "For example ~/Desktop/aiw_skata001" << endl;