<commit_before>//
// パズル固有スクリプト部 たわむれんが版 tawa.js v3.4.0
//
(function(){

var k = pzpr.consts;

pzpr.createCustoms('tawa', {
//---------------------------------------------------------
// マウス入力系
MouseEvent:{
	mouseinput : function(){
		if(this.owner.playmode){
			if(this.mousestart || this.mousemove){ this.inputcell();}
		}
		else if(this.owner.editmode){
			if(this.mousestart){ this.inputqnum();}
		}
	},

	// マウス入力時のセルID取得系
	getcell : function(){
		var pos = this.getpos(0), cand = pos.getc();
		return (!cand.isnull ? cand : pos.move(1,0).getc());
	},
	getpos : function(rc){
		var pc = this.owner.painter;
		return (new this.owner.Address(this.inputPoint.bx|0, (this.inputPoint.by>>1<<1)+1));
	}
},

//---------------------------------------------------------
// キーボード入力系
KeyEvent:{
	enablemake : true
},

TargetCursor:{
	// キー移動範囲のminx,maxx,miny,maxy設定関数オーバーライド
	adjust_init : function(){
		if(this.pos.getc().isnull){
			this.pos.bx++;
		}
	},

	movedir_cursor : function(dir,mv){
		this.pos.movedir(dir,mv);

		if(dir===k.UP){
			if(this.pos.bx===this.maxx || (this.pos.bx>this.minx && (this.pos.by&2)===0)){ this.pos.bx--;}
			else{ this.pos.bx++;}
		}
		else if(dir===k.DN){
			if(this.pos.bx===this.minx || (this.pos.bx<this.maxx && (this.pos.by&2)===2)){ this.pos.bx++;}
			else{ this.pos.bx--;}
		}
	}
},

//---------------------------------------------------------
// 盤面管理系
Cell:{
	numberIsWhite : true,

	maxnum : 6,
	minnum : 0
},
Board:{
	qcols : 6,	// ※本スクリプトでは一番上の段のマスの数を表すこととする.
	qrows : 7,
	shape : 3,	// 2段目は => 0:左右引っ込み 1:右のみ出っ張り 2:左のみ出っ張り 3:左右出っ張り

	setShape : function(val){
		this.shape=val;
		this.setminmax();
	},

	estimateSize : function(type, col, row){
		var total = 0;
		if     (this.shape==0){ total = (row>>1)*(2*col-1)+((row%2==1)?col:0);}
		else if(this.shape==3 || this.shape==undefined){ total = (row>>1)*(2*col+1)+((row%2==1)?col:0);}
		else{ total = col*row;}

		return total;
	},
	setposCells : function(){
		this.cellmax = this.cell.length;
		for(var id=0;id<this.cellmax;id++){
			var obj = this.cell[id];
			obj.id = id;
			obj.isnull = false;

			if(this.shape==0){
				var row = (((2*id)/(2*this.qcols-1))|0);
				obj.bx = (((2*id)%(2*this.qcols-1))|0)+1;
				obj.by = row*2+1;
			}
			else if(this.shape==1){
				var row = ((id/this.qcols)|0);
				obj.bx = ((id%this.qcols)|0)*2+(!!(row&1)?1:0)+1;
				obj.by = row*2+1;
			}
			else if(this.shape==2){
				var row = ((id/this.qcols)|0);
				obj.bx = ((id%this.qcols)|0)*2+(!(row&1)?1:0)+1;
				obj.by = row*2+1;
			}
			else if(this.shape==3){
				var row = (((2*id+1)/(2*this.qcols+1))|0);
				obj.bx = (((2*id+1)%(2*this.qcols+1))|0)+1;
				obj.by = row*2+1;
			}
		}
	},
	setminmax : function(){
		this.minbx = 0;
		this.minby = 0;
		this.maxbx = 2*this.qcols + [0,1,1,2][this.shape];
		this.maxby = 2*this.qrows;

		this.owner.cursor.setminmax();
	},

	getc : function(bx,by,qc,qr){
		var id = null;
		if(qc===(void 0)){ qc=this.qcols; qr=this.qrows;}
		if(bx>=this.minbx+1 && bx<=this.maxbx-1 && by>=this.minby+1 && by<=this.maxby-1){
			var cy = (by>>1);	// 上から数えて何段目か(0～qrows-1)
			if     (this.shape===0){ if(!!((bx+cy)&1)){ id = ((bx-1)+cy*(2*qc-1))>>1;}}
			else if(this.shape===1){ if(!!((bx+cy)&1)){ id = ((bx-1)+cy*(2*qc  ))>>1;}}
			else if(this.shape===2){ if( !((bx+cy)&1)){ id = ((bx-1)+cy*(2*qc  ))>>1;}}
			else if(this.shape===3){ if( !((bx+cy)&1)){ id = ((bx-1)+cy*(2*qc+1))>>1;}}
		}

		return (id!==null ? this.cell[id] : this.emptycell);<commit_msg>tawa: カーソル移動時に移動前のセルが正しく取得できないのを修正<commit_after>//
// パズル固有スクリプト部 たわむれんが版 tawa.js v3.4.0
//
(function(){

var k = pzpr.consts;

pzpr.createCustoms('tawa', {
//---------------------------------------------------------
// マウス入力系
MouseEvent:{
	mouseinput : function(){
		if(this.owner.playmode){
			if(this.mousestart || this.mousemove){ this.inputcell();}
		}
		else if(this.owner.editmode){
			if(this.mousestart){ this.inputqnum();}
		}
	},

	// マウス入力時のセルID取得系
	getcell : function(){
		var pos = this.getpos(0), cand = pos.getc();
		return (!cand.isnull ? cand : pos.move(1,0).getc());
	},
	getpos : function(rc){
		var pc = this.owner.painter;
		return (new this.owner.Address(this.inputPoint.bx|0, (this.inputPoint.by>>1<<1)+1));
	}
},

//---------------------------------------------------------
// キーボード入力系
KeyEvent:{
	enablemake : true
},

TargetCursor:{
	// キー移動範囲のminx,maxx,miny,maxy設定関数オーバーライド
	adjust_init : function(){
		if(this.pos.getc().isnull){
			this.pos.bx++;
		}
	},

	movedir_cursor : function(dir,mv){
		this.pos.movedir(dir,mv);

		if(dir===k.UP){
			if(this.pos.bx===this.maxx || (this.pos.bx>this.minx && (this.pos.by&2)===0)){ this.pos.bx--;}
			else{ this.pos.bx++;}
		}
		else if(dir===k.DN){
			if(this.pos.bx===this.minx || (this.pos.bx<this.maxx && (this.pos.by&2)===2)){ this.pos.bx++;}
			else{ this.pos.bx--;}
		}
	}
},

//---------------------------------------------------------
// 盤面管理系
Cell:{
	numberIsWhite : true,

	maxnum : 6,
	minnum : 0
},
Board:{
	qcols : 6,	// ※本スクリプトでは一番上の段のマスの数を表すこととする.
	qrows : 7,
	shape : 3,	// 2段目は => 0:左右引っ込み 1:右のみ出っ張り 2:左のみ出っ張り 3:左右出っ張り

	setShape : function(val){
		this.shape=val;
		this.setminmax();
	},

	estimateSize : function(type, col, row){
		var total = 0;
		if     (this.shape==0){ total = (row>>1)*(2*col-1)+((row%2==1)?col:0);}
		else if(this.shape==3 || this.shape==undefined){ total = (row>>1)*(2*col+1)+((row%2==1)?col:0);}
		else{ total = col*row;}

		return total;
	},
	setposCells : function(){
		this.cellmax = this.cell.length;
		for(var id=0;id<this.cellmax;id++){
			var obj = this.cell[id];
			obj.id = id;
			obj.isnull = false;

			if(this.shape==0){
				var row = (((2*id)/(2*this.qcols-1))|0);
				obj.bx = (((2*id)%(2*this.qcols-1))|0)+1;
				obj.by = row*2+1;
			}
			else if(this.shape==1){
				var row = ((id/this.qcols)|0);
				obj.bx = ((id%this.qcols)|0)*2+(!!(row&1)?1:0)+1;
				obj.by = row*2+1;
			}
			else if(this.shape==2){
				var row = ((id/this.qcols)|0);
				obj.bx = ((id%this.qcols)|0)*2+(!(row&1)?1:0)+1;
				obj.by = row*2+1;
			}
			else if(this.shape==3){
				var row = (((2*id+1)/(2*this.qcols+1))|0);
				obj.bx = (((2*id+1)%(2*this.qcols+1))|0)+1;
				obj.by = row*2+1;
			}
		}
	},
	setminmax : function(){
		this.minbx = 0;
		this.minby = 0;
		this.maxbx = 2*this.qcols + [0,1,1,2][this.shape];
		this.maxby = 2*this.qrows;

		this.owner.cursor.setminmax();
	},

	getc : function(bx,by,qc,qr){
		var id = null;
		if(qc===(void 0)){ qc=this.qcols; qr=this.qrows;}
		if(bx>=this.minbx+1 && bx<=this.maxbx-1 && by>=this.minby+1 && by<=this.maxby-1){
			var cy = (by>>1);	// 上から数えて何段目か(0～qrows-1)
			if     (this.shape===0){ if(!!((bx+cy)&1)){ id = ((bx-1)+cy*(2*qc-1))>>1;}}
			else if(this.shape===1){ if(!!((bx+cy)&1)){ id = ((bx-1)+cy*(2*qc  ))>>1;}}
			else if(this.shape===2){ if( !((bx+cy)&1)){ id = ((bx-1)+cy*(2*qc  ))>>1;}}
			else if(this.shape===3){ if( !((bx+cy)&1)){ id = ((bx-1)+cy*(2*qc+1))>>1;}}
		}

		return (id!==null ? this.cell[id] : this.emptycell);
	},
	getobj : function(bx,by,qc,qr){
		return this.getc(bx,by,qc,qr);
{'fraction_non_alphanumeric': 0.29580668088130774, 'fraction_numerical': 0.03525230987917555, 'mean_word_length': 2.8851463279955825, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2713152', 'n_tokens_mistral': 3655, 'n_tokens_neox': 3300, 'n_words': 448}