2020-03-29 20:42:08 +02:00
var g _current _core
temp = {
//
// Core Click
//
// boilerplate
core _click : {
execute : function ( ) {
var x _core = g _current _core
updateAllCores ( )
endHost ( )
write ( coreClickString ( x _core ) )
launchAdventureFromSlug ( 'core_click_callback' )
refreshMenu ( )
}
} ,
core _click _callback : {
execute : function ( ) {
var x _core = g _current _core ,
options = [ ]
options . push ( {
title : "Change Form" ,
callback : function ( ) {
launchAdventureFromSlug ( 'core_change_form' )
}
} )
if ( ! x _core . ailments . length ) {
var x _exploit = getAvailableExploitResearch ( x _core )
var unclickable _string
var estimate _number = 0
if ( ! research _exploits ) {
unclickable _string = "You have not yet researched the ability to create Exploits."
} else {
unclickable _string = "No exploits available for " + x _core . os
switch ( true ) {
case ( x _exploit == 'discovered' ) :
unclickable _string = "You have already researched all exploits for " + x _core . os
break ;
case ( ! ! x _exploit ) :
unclickable _string = false
estimate _number = 400
break ;
}
}
options . push ( {
title : x _core . os + " Exploit" ,
estimate : estimateProcessByWeight ( estimate _number ) ,
unclickable : unclickable _string ,
callback : function ( ) {
var x _process = { slug : 'core_research_os_' + x _core . title , a : "Researching Exploit" , w : 400 ,
c : function ( ) {
addBuffer ( "<span class='exe'>Exploit Researched</span>" )
addBuffer ( x _exploit . to _s ( ) )
addBuffer ( x _exploit . exe )
writeBuffer ( )
addExploit ( x _exploit )
}
}
setProcessToCore ( x _core , x _process )
endAdventure ( )
}
} )
var upgradeable _os = coreClickableUpgradeOS ( x _core )
options . push ( {
title : "Research New OS" ,
unclickable : upgradeable _os ? false : "The " + x _core . architecture + " Architecture does not allow an upgrade to the " + x _core . os + " Operating System" ,
estimate : upgradeable _os ? estimateProcessByWeight ( 500 ) : undefined ,
callback : function ( ) {
var x _process = { slug : 'upgrade_os_' + x _core . title , a : "Researching OS upgrade" , w : 500 , c : function ( ) {
x _core . os = upgradeable _os
addOsToMemory ( upgradeable _os )
addBuffer ( "<span class='exe'>" + upgradeable _os + "</span> researched and upgraded on the " + x _core . title )
addBuffer ( coreClickString ( x _core ) )
writeBuffer ( )
}
}
setProcessToCore ( x _core , x _process )
endAdventure ( )
}
} )
unclickable _string = overclockUnclickable ( x _core )
estimate _number = unclickable _string ? 0 : 500
options . push ( {
unclickable : unclickable _string ,
estimate : estimateProcessByWeight ( estimate _number ) ,
title : "Overclock Core" ,
callback : function ( ) {
var x _process = { slug : 'core_overclock_' + x _core . title , a : "Overclocking" , w : estimate _number , c : function ( ) {
addBuffer ( "<span class='exe'>" + x _core . title + " Overclocked</span>" )
2020-05-06 20:37:41 +02:00
addBuffer ( "You apply your understandings of computation and reform the Core into a more efficient format. You are now able to increase the clock speed and increase processing power." )
2020-03-29 20:42:08 +02:00
addBuffer ( "Core Speed: 2x" )
writeBuffer ( )
x _core . power ++
x _core . overclocked = true
}
}
setProcessToCore ( x _core , x _process )
endAdventure ( )
}
} )
}
options . push ( {
title : "Help" ,
callback : function ( ) {
write ( coreClickString ( x _core ) )
launchAdventureFromSlug ( 'core_diagnostics' )
}
} )
var x _adventure = {
header : x _core . title ,
cancel : 'Exit' ,
options : options
}
setAdventure ( x _adventure )
}
} ,
// change form
core _change _form : {
execute : function ( ) {
var x _core = g _current _core
var x _adventure = {
header : "Change Form of " + x _core . title ,
back : 'core_click_callback' ,
options : [
{
title : "Change Operating System" ,
callback : function ( ) {
launchAdventureFromSlug ( 'core_change_form_os' )
}
} ,
{
title : "Change Architecture" ,
callback : function ( ) {
launchAdventureFromSlug ( 'core_change_form_arch' )
}
} ,
]
}
setAdventure ( x _adventure )
}
} ,
core _change _form _arch : {
execute : function ( ) {
var x _core = g _current _core ,
options = [ ] ,
versions
$ . each ( g _architecture , function ( type , versions ) {
versions = Object . keys ( versions )
$ . each ( versions , function ( i , version ) {
options . push ( {
title : type + " " + version ,
unclickable : ( x _core . architecture == type + "-" + version ) ? "This is the current Core Architecture" : false ,
callback : function ( ) {
changeFormArch ( x _core , type , version )
launchAdventureFromSlug ( 'core_click_callback' )
}
} )
} )
} )
var x _adventure = {
header : "Current Architecture: " + x _core . architecture . split ( '-' ) . join ( ' ' ) ,
back : 'core_click_callback' ,
options : options
}
setAdventure ( x _adventure )
}
} ,
core _change _form _os : {
execute : function ( ) {
var x _core = g _current _core ,
options = [ ] ,
versions
$ . each ( g _os , function ( type , versions ) {
versions = Object . keys ( versions )
$ . each ( versions , function ( i , version ) {
options . push ( {
title : type + " " + version ,
unclickable : ( x _core . os == type + "-" + version ) ? "This is the current Core Operating System" : false ,
callback : function ( ) {
changeFormOs ( x _core , type , version )
launchAdventureFromSlug ( 'core_click_callback' )
}
} )
} )
} )
var x _adventure = {
header : "Current OS: " + x _core . os . split ( '-' ) . join ( ' ' ) ,
back : 'core_click_callback' ,
options : options
}
setAdventure ( x _adventure )
}
} ,
// research help
core _diagnostics : {
execute : function ( ) {
var x _core = g _current _core
var x _adventure = {
header : 'Help' ,
back : 'core_click_callback' ,
options : [
//{
// title:"Diagnose Core",
// callback: function(){
// write(coreClickString(x_core))
// launchAdventureFromSlug('core_diagnostics')
// }
//},
{
title : "List Protocols" ,
callback : function ( ) {
writeProtocols ( )
launchAdventureFromSlug ( 'core_diagnostics' )
}
} ,
{
title : "List Exploits" ,
callback : function ( ) {
writeAttacks ( )
launchAdventureFromSlug ( 'core_diagnostics' )
}
} ,
{
title : "List Knowledge" ,
callback : function ( ) {
writeKnowledge ( )
launchAdventureFromSlug ( 'core_diagnostics' )
}
} ,
{
title : "List OS Forms" ,
callback : function ( ) {
writeKnownOS ( )
launchAdventureFromSlug ( 'core_diagnostics' )
}
} ,
{
title : "List Architecture Forms" ,
callback : function ( ) {
writeKnownArch ( )
launchAdventureFromSlug ( 'core_diagnostics' )
}
} ,
]
}
setAdventure ( x _adventure )
}
} ,
}
$ . each ( temp , function ( key , val ) {
g _adventures [ key ] = val
} )
overclockUnclickable = function ( x _core ) {
if ( x _core . power >= g _max _core _power ) {
return "Maximum Core power reached"
} else {
return false
}
}
//
// Core CLick Support
//
changeFormArch = function ( x _core , type , version ) {
var x _process = { slug : 'change_arch_' + x _core . slug , a : "Changing Architecture" , w : 50 , c : function ( ) {
addBuffer ( "The Architecture of " + x _core . title + " has been changed to <span class='exe'>" + type + " " + version + "</span>" )
x _core . architecture = type + "-" + version
checkCoreArchOsAilment ( x _core )
addBuffer ( coreClickString ( x _core ) )
writeBuffer ( )
}
}
setProcessToCore ( x _core , x _process )
}
changeFormOs = function ( x _core , type , version ) {
var x _process = { slug : 'change_os_' + x _core . slug , a : "Changing OS" , w : 50 , c : function ( ) {
addBuffer ( "The Operating System of " + x _core . title + " has been changed to <span class='exe'>" + type + " " + version + "</span>" )
x _core . os = type + "-" + version
checkCoreArchOsAilment ( x _core )
addBuffer ( coreClickString ( x _core ) )
writeBuffer ( )
}
}
setProcessToCore ( x _core , x _process )
}
checkCoreArchOsAilment = function ( x _core ) {
var os = x _core . os ,
arch = x _core . architecture
switch ( os ) {
case "MSDOS-16bit" :
if ( arch == "x86-32bit" || arch == "x86-16bit" )
return rmCoreAilment ( x _core , 'os_arch_mismatch' )
break ;
case "MSDOS-32bit" :
if ( arch == "x86-32bit" )
return rmCoreAilment ( x _core , 'os_arch_mismatch' )
break ;
case "Linux-16bit" :
if ( arch == "x86-32bit" || arch == "x86-16bit" )
return rmCoreAilment ( x _core , 'os_arch_mismatch' )
break ;
case "Linux-32bit" :
if ( arch == "x86-32bit" )
return rmCoreAilment ( x _core , 'os_arch_mismatch' )
break ;
case "Linux-32bit" :
if ( arch == "x86-32bit" )
return rmCoreAilment ( x _core , 'os_arch_mismatch' )
break ;
case "Solaris-32bit" :
if ( arch == "SPARC-32bit" )
return rmCoreAilment ( x _core , 'os_arch_mismatch' )
break
2020-04-18 14:18:07 +02:00
case "CellOS-32bit" :
if ( arch == "PowerPC-32bit" )
2020-03-29 20:42:08 +02:00
return rmCoreAilment ( x _core , 'os_arch_mismatch' )
break
}
return addCoreAilment ( x _core , 'os_arch_mismatch' )
}
addCoreAilment = function ( x _core , slug ) {
if ( ! x _core . ailments . includes ( slug ) ) {
x _core . ailments . push ( slug )
}
}
rmCoreAilment = function ( x _core , slug ) {
$ . each ( x _core . ailments , function ( i , ailment ) {
if ( slug == ailment ) x _core . ailments . splice ( i , 1 )
} )
}
coreClickString = function ( x _core ) {
var a = x _core . os . split ( '-' ) ,
osTitle = a [ 0 ] , osVersion = a [ 1 ] ,
a = x _core . architecture . split ( '-' ) ,
archTitle = a [ 0 ] , archVersion = a [ 1 ]
var output = "<span class='exe'>" + x _core . title + "</span>"
output += "<br>OS: " + osTitle + " " + osVersion
output += "<br>CPU: " + archTitle + " " + archVersion
output += "<br>Speed: " + coreSpeedOutput ( x _core )
$ . each ( x _core . ailments , function ( i , ailment ) {
switch ( ailment ) {
case 'os_arch_mismatch' :
output += "<br>Error: Incompatible Operating System"
}
} )
return output
}
coreSpeedOutput = function ( x _core ) {
return formatBytes ( Math . pow ( 2 , x _core . power + g _corepower - 2 ) * Math . pow ( 2 , g _level _core ) * 100000 , true ) + "Hz"
}
coreClickableUpgradeOS = function ( x _core ) {
if ( x _core . os == "MSDOS-16bit" && ! g _os [ 'MSDOS' ] [ '32bit' ] && x _core . architecture == 'x86-32bit' ) {
return "MSDOS-32bit"
} else {
return false
}
}