Fix: delete test_*.html files

This commit is contained in:
2018-06-07 18:33:54 +09:00
parent a6d79b57c6
commit c1efb24684
28 changed files with 584 additions and 1342 deletions
@@ -0,0 +1,39 @@
class ContentProgress {
constructor() {
let fontStyle = ContentProgress.DEFAULT_TEXT_FONT;
fontStyle.align = "right";
fontStyle.boundsAlignH = "right";
this.typingSpeedText = game.add.text(game.world.width - 300, 0, "", fontStyle)
.setTextBounds(0, 0, 200, ContentProgress.FONT_HEIGHT_PX);
// var grd = this.label.context.createLinearGradient(0, 0, 0, ContentProgress.FONT_HEIGHT_PX);
// grd.addColorStop(0, '#8ED6FF');
// grd.addColorStop(1, '#004CB3');
// this.label.fill = grd;
// this.scoreText.fill = grd;
// this.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
// this.label.stroke = '#000';
// this.label.strokeThickness = 3;
};
print(playingNumber, totalCount) {
if(playingNumber > totalCount)
return;
this.typingSpeedText.text = playingNumber + " / " + totalCount;
}
}
ContentProgress.FONT_HEIGHT_PX = 70;
ContentProgress.DEFAULT_TEXT_FONT = {
font: "38px Arial",
align: "center",
boundsAlignH: "center", // left, center. right
boundsAlignV: "middle", // top, middle, bottom
fill: "#fff"
};
+413
View File
@@ -0,0 +1,413 @@
/////////////////////////////
// TypingPractice
class TypingPractice {
create() {
self = this;
this.initTypingData();
sessionStorageManager.isNewBestRecrd = false;
game.stage.backgroundColor = '#4d4d4d';
// top
let backButton = new BackButton( () => {
sessionStorageManager.resetPlayingAppData();
location.href = '../../web/client/menu_typing_practice.html';
});
this.contentProgressText = new ContentProgress();
let fullscreenButton = new FullscreenButton(game);
// typing content
var typingAreaPositionY = 260;
var bar = game.add.graphics();
bar.beginFill(0x000000, 0.2);
bar.drawRect(0, typingAreaPositionY, GAME_SCREEN_SIZE.x, 120);
if(isTypingWordStage())
textStyleBasic.font = "bold 84px Arial";
else // Sentence stage
textStyleBasic.font = "bold 48px Arial";
this.textTypingContent = game.add.text(0, 2, "test", textStyleBasic)
.setTextBounds(0, typingAreaPositionY, GAME_SCREEN_SIZE.x, 120)
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2)
.addColor(TypingPractice.COLOR_CONTENT_WRONG, 0);
textStyleBasic.font = "32px Arial";
var textDoneColor = [ '#99994d', '#77774d', '#66664d' ];
this.textTypingContentsDone = [];
this.textTypingRecordsDone = [];
for(var i = 0; i < TypingPractice.TYPING_CONTENT_DONE_COUNT; i++) {
this.textTypingContentsDone[i] = game.add.text(0, 2, "test", textStyleBasic)
.setTextBounds(0, typingAreaPositionY - 50 - i * 50, GAME_SCREEN_SIZE.x, 40)
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2)
.addColor(textDoneColor[i], 0);
var scorePositionX = 780;
if(isTypingWordStage())
scorePositionX = 600;
this.textTypingRecordsDone[i] = game.add.text(0, 2, "", textStyleBasic)
.setTextBounds(scorePositionX, typingAreaPositionY - 50 - i * 50, 200, 40)
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2)
.addColor(textDoneColor[i], 0);
}
var textPreviewColor = [ '#999999', '#888888', '#777777' ];
this.textTypingContentPreview = [];
for(var i = 0; i < TypingPractice.TYPING_CONTENT_PREVIEW_COUNT; i++) {
this.textTypingContentPreview[i] = game.add.text(0, 2, "test", textStyleBasic)
.setTextBounds(0, typingAreaPositionY + 130 + i * 50, GAME_SCREEN_SIZE.x, 40)
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2)
.addColor(textPreviewColor[i], 0);
}
// input text
this.inputTextContent = new InputTypeText(game.world.centerX, typingAreaPositionY + 360);
this.inputTextContent.anchor.set(0.5);
this.inputTextContent.canvasInput.value('');
this.inputTextContent.canvasInput.focus();
// inputTextContent.canvasInput._onkeydown = this.checkInputText;
// inputTextContent.canvasInput._onkeyup = function() {
this.inputTextContent.canvasInput._onkeyup = function() {
self.checkTypingContents(event);
}
// bottom
let screenBottom = new ScreenBottom();
screenBottom.makeBottomLine();
// screenBottom.printBottomLeftText("");
screenBottom.printBottomCenterText(sessionStorageManager.playingAppKoreanName);
screenBottom.printBottomRightText(sessionStorageManager.playerName);
this.startGame();
// this.countDown();
}
/*
countDown() {
const style = { font: "bold 200px Arial", fill: "#fff", boundsAlignH: "center", boundsAlignV: "middle" };
this.countDownText = game.add.text(0, 0, "", style);
this.countDownText.setTextBounds(0, 0, game.world.width, game.world.height);
this.countDownText.stroke = "#333";
this.countDownText.strokeThickness = 50;
this.countDownNumber = 3;
if(isDebugMode())
this.countDownNumber = 1;
this.tweenCountDown();
}
tweenCountDown() {
if(this.countDownNumber === 0) {
this.startGame();
return;
}
this.countDownText.text = this.countDownNumber.toString();
this.countDownText.alpha = 1;
let countDownTween = game.add.tween(this.countDownText);
countDownTween.to( { alpha: 0 }, GAME_SCREEN_SIZE.x, Phaser.Easing.Linear.None, true);
countDownTween.onComplete.add(this.tweenCountDown, this);
this.countDownNumber--;
}
*/
startGame() {
this.showTypingPracticeContents();
this.showPlayingWordNumber();
}
gameOver() {
let gameOverText = new GameOverText();
game.time.events.add(Phaser.Timer.SECOND * 2, this.goResult, this);
}
goResult() {
sessionStorageManager.record = this.typingRecordTotal;
if(sessionStorageManager.record > sessionStorageManager.bestRecord)
sessionStorageManager.bestRecord = sessionStorageManager.record;
location.href = '../../web/client/result.html';
}
initTypingData() {
this.typingContents = this.getTypingPracticeContents();
var randomContents = Phaser.ArrayUtils.shuffle(this.typingContents);
this.wordCountForStage = TypingPractice.WORD_COUNT_FOR_STAGE;
if(isDebugMode())
this.wordCountForStage = 3;
this.typingRandomContents = randomContents.slice(1, this.wordCountForStage + 1); // start Num, end Num (not index)
this.typingContentLength = this.typingContents.length;
this.typingIndex = 0;
this.isTyping = false;
this.timeTypingStart = 0;
this.timeTypingEnd = 0;
this.typingLetterCountTotal = 0;
this.typingRecordTotal = 0;
}
getTypingPracticeContents() {
var TypingPracticeContents = this.loadTestContent();
// console.log('playingStageData.language : ' + playingStageData.language);
// console.log('playingStageData.level : ' + playingStageData.level);
// console.log('TypingPracticeContents : ' + TypingPracticeContents);
this.typingRecordForLines = [];
this.typingElapsedTime = [];
for(var i = 0; i < TypingPracticeContents.length; i++) {
this.typingRecordForLines[i] = 0;
this.typingElapsedTime[i] = 0;
}
return TypingPracticeContents;
}
loadTestContent() {
let appName = "";
if(isTypingTestStage())
appName = sessionStorageManager.playingAppName.substring(5);
else if(isTypingPracticeStage())
appName = sessionStorageManager.playingAppName.substring(9);
var testContent = [];
switch(appName) {
case "korean_basic":
testContent = koreanBasicWordList;
break;
case "korean_left_upper":
testContent = koreanLeftUpperWordList;
break;
case "korean_second_finger":
testContent = koreanSecondFingerWordList;
break;
case "korean_right_upper":
testContent = koreanRightUpperWordList;
break;
case "korean_left_lower":
testContent = koreanLeftLowerWordList;
break;
case "korean_right_lower":
testContent = koreanRightLowerWordList;
break;
case "korean_left_upper_double":
testContent = koreanLeftUpperDoubleWordList;
break;
case "korean_right_upper_double":
testContent = koreanRightUpperDoubleWordList;
break;
case "korean_word":
testContent = koreanWordList;
break;
case "korean_sentence":
testContent = koreanSentenceList;
break;
case "english_basic":
testContent = englishBasicWordList;
break;
case "english_left_upper":
testContent = englishLeftUpperWordList;
break;
case "english_second_finger":
testContent = englishSecondFingerWordList;
break;
case "english_right_upper":
testContent = englishRightUpperWordList;
break;
case "english_left_lower":
testContent = englishLeftLowerWordList;
break;
case "english_right_lower":
testContent = englishRightLowerWordList;
break;
case "english_word":
testContent = englishWordList;
break;
case "english_sentence":
testContent = englishSentenceList;
break;
}
return testContent;
}
showTypingPracticeContents() {
for(var i = 0; i < TypingPractice.TYPING_CONTENT_DONE_COUNT; i++) {
var doneIndex = this.typingIndex - i - 1;
if(doneIndex < 0) {
this.textTypingContentsDone[i].text = "";
this.textTypingRecordsDone[i].text = "";
} else {
this.textTypingContentsDone[i].text = this.typingRandomContents[doneIndex];
this.textTypingRecordsDone[i].text = Math.floor(this.typingRecordForLines[doneIndex]);
}
}
if(this.typingIndex == this.wordCountForStage) {
this.textTypingContent.text = "";
return;
}
this.textTypingContent.text = this.typingRandomContents[this.typingIndex];
for(var i = 0; i < TypingPractice.TYPING_CONTENT_PREVIEW_COUNT; i++) {
var previewIndex = this.typingIndex + i + 1;
if(previewIndex < this.typingRandomContents.length)
this.textTypingContentPreview[i].text = this.typingRandomContents[previewIndex];
else
this.textTypingContentPreview[i].text = "";
}
}
resetTypingContent() {
this.textTypingContent.clearColors();
this.textTypingContent.addColor(TypingPractice.COLOR_CONTENT_WRONG, 0);
this.inputTextContent.canvasInput.value('');
}
checkTypingContents(evnet) {
if(event.keyCode == Phaser.Keyboard.ENTER) {
// console.log("### enter ###");
var inputContent = this.inputTextContent.canvasInput.value();
var typingContent = this.typingRandomContents[this.typingIndex];
if(inputContent == typingContent) {
this.calculateTypingRecord(typingContent);
this.playNextContent();
if(this.typingIndex == this.wordCountForStage)
this.goResult();
// this.state.start('TypingPracticeResult');
}
}
else {
// console.log(this.inputTextContent.canvasInput.value());
if(this.isTyping == false) {
// console.log(event);
this.setTimeTypingStart();
}
this.showTypingContentHighlight();
}
}
showTypingContentHighlight() {
var typingContent = this.typingRandomContents[this.typingIndex];
var inputContent = this.inputTextContent.canvasInput.value();
this.textTypingContent.clearColors();
this.textTypingContent.addColor(TypingPractice.COLOR_CONTENT_RIGHT, 0);
if(typingContent == null)
return;
var typingContentLength = typingContent.length;
for(var i = 0; i < typingContentLength; i++) {
// console.log("typingContent.charAt(i) : " + typingContent.charAt(i));
// console.log("inputContent.charAt(i) : " + inputContent.charAt(i));
if(typingContent.charAt(i) != inputContent.charAt(i)) {
this.textTypingContent.addColor(TypingPractice.COLOR_CONTENT_WRONG, i);
return;
}
}
}
calculateTypingRecord(typingContent) {
// console.log('입력 단어 : ' + this.typingRandomContents[this.typingIndex]);
this.isTyping = false;
this.timeTypingEnd = game.time.elapsedSince(0);
// console.log('this.timeTypingEnd : ' + this.timeTypingEnd);
var elapsedTimeMS = this.timeTypingEnd - this.timeTypingStart;
// console.log('elapsedTimeMS : ' + elapsedTimeMS);
var typingContentLength = StringUtil.getUnicodeAlphabetCount(typingContent);
// console.log('typingContentLength : ' + typingContentLength);
var typingContentPlusEnterCount = typingContentLength + TypingPractice.TYPING_COUNT_PLUS_ENTER;
var typingRecord = (typingContentPlusEnterCount + TypingPractice.TYPING_COUNT_PLUS_ENTER) * 60000 / elapsedTimeMS;
this.typingElapsedTime[this.typingIndex] = elapsedTimeMS;
this.typingLetterCountTotal += typingContentPlusEnterCount;
this.typingRecordForLines[this.typingIndex] = typingRecord;
// console.log(this.typingRecordForLines[this.typingIndex]);
var typingElapsedTimeTotal = 0;
for(let i = 0; i <= this.typingIndex; i++) {
// console.log('i : ' + i + ' - time : ' + this.typingElapsedTime[i]);
typingElapsedTimeTotal += this.typingElapsedTime[i];
}
this.typingRecordTotal = this.typingLetterCountTotal * 60000 / typingElapsedTimeTotal;
// console.log(this.typingLetterCountTotal);
// console.log(typingElapsedTimeTotal);
// console.log(typingRecordTotal);
// console.log('-------------- total --------------');
// console.log('typingLetterCountTotal : ' + this.typingLetterCountTotal);
// console.log('typingElapsedTimeTotal : ' + typingElapsedTimeTotal);
// console.log('typingRecordTotal : ' + typingRecordTotal);
// console.log('-----------------------------------');
}
playNextContent() {
this.typingIndex++;
this.showTypingPracticeContents();
this.showPlayingWordNumber();
this.resetTypingContent();
}
showPlayingWordNumber() {
this.contentProgressText.print(this.typingIndex + 1, this.wordCountForStage);
}
setTimeTypingStart() {
this.timeTypingStart = game.time.elapsedSince(0);
var timeGap = this.timeTypingStart - this.timeTypingEnd;
if(timeGap < 50)
return;
this.isTyping = true;
// console.log('last End : ' + this.timeTypingEnd);
// console.log('this.timeTypingStart : ' + this.timeTypingStart);
// console.log('time gap : ' + (this.timeTypingStart - this.timeTypingEnd));
}
}
TypingPractice.TYPING_CONTENT_PREVIEW_COUNT = 3;
TypingPractice.TYPING_CONTENT_DONE_COUNT = 3;
TypingPractice.TYPING_COUNT_PLUS_ENTER = 1;
TypingPractice.OFFSET_RIGHT_ALIGN = 10;
TypingPractice.WORD_COUNT_FOR_STAGE = 10;
// if(isDebugMode())
// WORD_COUNT_FOR_STAGE = 3;
TypingPractice.COLOR_CONTENT_WRONG = "#aaaaaa";
TypingPractice.COLOR_CONTENT_RIGHT = "#ffff4d";
+93
View File
@@ -0,0 +1,93 @@
/////////////////////////////
// Loading
// var x = 32;
// var y = 80;
class Loading {
preload() {
// this.game.load.image('loadingbar', './image/phaser.png');
}
create() {
// let userID = sessionStorage.getItem("UserID");
// console.log("userID : " + userID);
// this.game.stage.backgroundColor = '#4d4d4d';
// // Progress report
// this.textProgress = game.add.text(game.world.centerX, 100, '로딩중 . . .', textStyleBasic);
// this.textProgress.anchor.setTo(0.5, 0.4);
// this.textProgress.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
// // Preload bar
// this.preloadBar = this.add.sprite(game.world.centerX, game.world.centerY, 'loadingbar');
// this.preloadBar.anchor.setTo(0.5);
// this.preloadBar.alpha = 0;
this.game.load.onFileComplete.add(this.fileComplete, this);
this.game.load.onLoadComplete.add(this.loadComplete, this);
this.startLoading();
}
startLoading() {
this.game.load.image('icon_fullscreen', '../../../resources/image/icon/fullscreen_white.png');
// this.game.load.image('a', '../../../resources/image/icon/fullscreen_white.png');
// this.game.load.image('b', '../../../resources/image/icon/fullscreen_white.png');
// this.game.load.image('c', '../../../resources/image/icon/fullscreen_white.png');
// this.game.load.image('d', '../../../resources/image/icon/fullscreen_white.png');
// this.game.load.image('a', './image/phaser.png');
// this.game.load.image('b', './image/phaser.png');
// this.game.load.image('c', './image/phaser.png');
// this.game.load.image('d', './image/phaser.png');
// this.game.load.image('e', './image/phaser.png');
// this.game.load.image('g', './image/phaser.png');
// this.game.load.image('e', './image/phaser.png');
// this.game.load.image('f', './image/phaser.png');
// this.game.load.image('g', './image/phaser.png');
// this.game.load.image('h', './image/phaser.png');
// this.game.load.image('phaser', './image/phaser.png');
// this.game.load.spritesheet('button', './image/button_basic.png', 200, 100);
// this.game.load.image('star', './image/star_particle.png');
// this.game.load.image('medal_gold', './image/medal_gold.png');
// this.game.load.image('medal_silver', './image/medal_silver.png');
// this.game.load.image('medal_bronze', './image/medal_bronze.png');
this.game.load.start();
}
fileComplete(progress, cacheKey, success, totalLoaded, totalFiles) {
// this.preloadBar.alpha = progress / 100;
// console.log('progress : ' + progress);
// text.setText("File Complete: " + progress + "% - " + totalLoaded + " out of " + totalFiles);
// var newImage = game.add.image(x, y, cacheKey);
// newImage.scale.set(0.3);
// x += newImage.width + 20;
// if (x > 700)
// {
// x = 32;
// y += 332;
// }
}
loadComplete(progress, cacheKey, success, totalLoaded, totalFiles) {
// this.preloadBar.alpha = 1;
if(isDebugMode()) {
this.state.start('TypingPractice');
return;
}
this.state.start('TypingPractice');
// this.startMenu();
// this.startTypingTestStage();
// this.startTypingTestResult();
}
}
+16
View File
@@ -0,0 +1,16 @@
/////////////////////////////
// Main game
const CONTENT_ID = "Typing Practice";
let game = new Phaser.Game(
GAME_SCREEN_SIZE.x, GAME_SCREEN_SIZE.y,
Phaser.CANVAS, CONTENT_ID,
this, false, false
);
game.state.add('Loading', Loading);
game.state.start('Loading');
game.state.add('TypingPractice', TypingPractice);
// game.state.add('Menu', Menu);
+2 -4
View File
@@ -188,9 +188,8 @@ class TypingTest {
if(isTypingTestStage())
appName = sessionStorageManager.playingAppName.substring(5);
else if(isTypingPracticeStage())
appName = sessionStorageManager.playingAppName.substring(5);
else
appName = sessionStorageManager.playingAppName.substring(5);
appName = sessionStorageManager.playingAppName.substring(9);
var testContent = [];
switch(appName) {
case "korean_basic":
@@ -366,7 +365,6 @@ class TypingTest {
// console.log(typingElapsedTimeTotal);
// console.log(typingRecordTotal);
// this.textTypingRecordTotal.text = Math.floor(typingRecordTotal);
this.averageTypingSpeedText.print(Math.floor(this.typingRecordTotal));
// console.log('-------------- total --------------');
// console.log('typingLetterCountTotal : ' + this.typingLetterCountTotal);